From 0ca063c5dc961c4aa17373f4b33fb54c51c8c8d6 Mon Sep 17 00:00:00 2001 From: Michael Perrotte Date: Tue, 24 Sep 2019 15:23:53 -0400 Subject: [PATCH 01/27] npm-lifecycle@3.1.4 - fix: filter functions and undefined out of makeEnv (@isaacs) --- node_modules/npm-lifecycle/CHANGELOG.md | 10 ++++++++++ node_modules/npm-lifecycle/index.js | 7 ++++++- node_modules/npm-lifecycle/package.json | 22 +++++++++++----------- package-lock.json | 6 +++--- package.json | 2 +- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/node_modules/npm-lifecycle/CHANGELOG.md b/node_modules/npm-lifecycle/CHANGELOG.md index c5449670d5b96..ccdd777ee1975 100644 --- a/node_modules/npm-lifecycle/CHANGELOG.md +++ b/node_modules/npm-lifecycle/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [3.1.4](https://github.com/npm/lifecycle/compare/v3.1.3...v3.1.4) (2019-09-18) + + +### Bug Fixes + +* filter functions and undefined out of makeEnv ([10c0c08](https://github.com/npm/lifecycle/commit/10c0c08)) + + + ## [3.1.3](https://github.com/npm/lifecycle/compare/v3.1.2...v3.1.3) (2019-08-12) diff --git a/node_modules/npm-lifecycle/index.js b/node_modules/npm-lifecycle/index.js index f775155d5eb66..337de71416879 100644 --- a/node_modules/npm-lifecycle/index.js +++ b/node_modules/npm-lifecycle/index.js @@ -458,12 +458,17 @@ function makeEnv (data, opts, prefix, env) { return } var value = opts.config[i] - if (value instanceof Stream || Array.isArray(value)) return + if (value instanceof Stream || Array.isArray(value) || typeof value === 'function') return if (i.match(/umask/)) value = umask.toString(value) + if (!value) value = '' else if (typeof value === 'number') value = '' + value else if (typeof value !== 'string') value = JSON.stringify(value) + if (typeof value !== 'string') { + return + } + value = value.indexOf('\n') !== -1 ? JSON.stringify(value) : value diff --git a/node_modules/npm-lifecycle/package.json b/node_modules/npm-lifecycle/package.json index 5eed875c7b7eb..beeb598957898 100644 --- a/node_modules/npm-lifecycle/package.json +++ b/node_modules/npm-lifecycle/package.json @@ -1,19 +1,19 @@ { - "_from": "npm-lifecycle@3.1.3", - "_id": "npm-lifecycle@3.1.3", + "_from": "npm-lifecycle@3.1.4", + "_id": "npm-lifecycle@3.1.4", "_inBundle": false, - "_integrity": "sha512-M0QmmqbEHBXxDrmc6X3+eKjW9+F7Edg1ENau92WkYw1sox6wojHzEZJIRm1ItljEiaigZlKL8mXni/4ylAy1Dg==", + "_integrity": "sha512-tgs1PaucZwkxECGKhC/stbEgFyc3TGh2TJcg2CDr6jbvQRdteHNhmMeljRzpe4wgFAXQADoy1cSqqi7mtiAa5A==", "_location": "/npm-lifecycle", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "npm-lifecycle@3.1.3", + "raw": "npm-lifecycle@3.1.4", "name": "npm-lifecycle", "escapedName": "npm-lifecycle", - "rawSpec": "3.1.3", + "rawSpec": "3.1.4", "saveSpec": null, - "fetchSpec": "3.1.3" + "fetchSpec": "3.1.4" }, "_requiredBy": [ "#USER", @@ -21,10 +21,10 @@ "/libcipm", "/libnpm" ], - "_resolved": "https://registry.npmjs.org/npm-lifecycle/-/npm-lifecycle-3.1.3.tgz", - "_shasum": "09e9b0b6686e85fd53bab82364386222d97a3730", - "_spec": "npm-lifecycle@3.1.3", - "_where": "/Users/isaacs/dev/npm/cli", + "_resolved": "https://registry.npmjs.org/npm-lifecycle/-/npm-lifecycle-3.1.4.tgz", + "_shasum": "de6975c7d8df65f5150db110b57cce498b0b604c", + "_spec": "npm-lifecycle@3.1.4", + "_where": "/Users/mperrotte/npminc/cli", "author": { "name": "Mike Sherov" }, @@ -82,5 +82,5 @@ "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "3.1.3" + "version": "3.1.4" } diff --git a/package-lock.json b/package-lock.json index 37297b2f6bad4..026c686e6fef9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3780,9 +3780,9 @@ "dev": true }, "npm-lifecycle": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/npm-lifecycle/-/npm-lifecycle-3.1.3.tgz", - "integrity": "sha512-M0QmmqbEHBXxDrmc6X3+eKjW9+F7Edg1ENau92WkYw1sox6wojHzEZJIRm1ItljEiaigZlKL8mXni/4ylAy1Dg==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/npm-lifecycle/-/npm-lifecycle-3.1.4.tgz", + "integrity": "sha512-tgs1PaucZwkxECGKhC/stbEgFyc3TGh2TJcg2CDr6jbvQRdteHNhmMeljRzpe4wgFAXQADoy1cSqqi7mtiAa5A==", "requires": { "byline": "^5.0.0", "graceful-fs": "^4.1.15", diff --git a/package.json b/package.json index 9b64923c418bd..22d3f538ab1aa 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "npm-audit-report": "^1.3.2", "npm-cache-filename": "~1.0.2", "npm-install-checks": "~3.0.0", - "npm-lifecycle": "^3.1.3", + "npm-lifecycle": "^3.1.4", "npm-package-arg": "^6.1.1", "npm-packlist": "^1.4.4", "npm-pick-manifest": "^3.0.2", From 5df6b0ea2e3106ba65bba649cc8d7f02f4738236 Mon Sep 17 00:00:00 2001 From: Michael Perrotte Date: Tue, 24 Sep 2019 15:26:22 -0400 Subject: [PATCH 02/27] libcipm@4.0.4 - fix: pack git directories properly (@claudiahdz) - respect no-optional argument (@cruzdanilo) --- node_modules/libcipm/CHANGELOG.md | 10 ++++++++++ node_modules/libcipm/index.js | 10 ++++++++-- node_modules/libcipm/lib/extract.js | 3 ++- node_modules/libcipm/package.json | 22 +++++++++++----------- package-lock.json | 6 +++--- package.json | 2 +- 6 files changed, 35 insertions(+), 18 deletions(-) diff --git a/node_modules/libcipm/CHANGELOG.md b/node_modules/libcipm/CHANGELOG.md index 26cf2d224cfb0..de37a13c2d78c 100644 --- a/node_modules/libcipm/CHANGELOG.md +++ b/node_modules/libcipm/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [4.0.4](https://github.com/npm/libcipm/compare/v4.0.3...v4.0.4) (2019-09-24) + + +### Bug Fixes + +* pack git directories properly ([576ab36](https://github.com/npm/libcipm/commit/576ab36)), closes [#4](https://github.com/npm/libcipm/issues/4) + + + ## [4.0.3](https://github.com/npm/libcipm/compare/v4.0.2...v4.0.3) (2019-08-12) diff --git a/node_modules/libcipm/index.js b/node_modules/libcipm/index.js index 7c9b59f62d44d..50f338c602679 100644 --- a/node_modules/libcipm/index.js +++ b/node_modules/libcipm/index.js @@ -244,7 +244,10 @@ class Installer { /^dev(elopment)?$/.test(this.opts.also) ) const includeProd = !/^dev(elopment)?$/.test(this.opts.only) - return (dep.dev && includeDev) || (!dep.dev && includeProd) + const includeOptional = includeProd && this.opts.optional + return (dep.dev && includeDev) || + (dep.optional && includeOptional) || + (!dep.dev && !dep.optional && includeProd) } updateJson (tree) { @@ -370,7 +373,10 @@ class Installer { pkg, stage, pkgPath, LifecycleOpts(this.opts).concat({ // TODO: can be removed once npm-lifecycle is updated to modern // config practices. - config: Object.assign({}, this.opts, { log: null }), + config: Object.assign({}, this.opts, { + log: null, + dirPacker: null + }), dir: this.prefix })) ).tap(() => { this.timings.scripts += Date.now() - start }) diff --git a/node_modules/libcipm/lib/extract.js b/node_modules/libcipm/lib/extract.js index 5681d1ce8cacd..f87d2c791d40e 100644 --- a/node_modules/libcipm/lib/extract.js +++ b/node_modules/libcipm/lib/extract.js @@ -12,7 +12,8 @@ let workerFarm const ENABLE_WORKERS = false const ExtractOpts = figgyPudding({ - log: {} + log: {}, + dirPacker: {} }) module.exports = { diff --git a/node_modules/libcipm/package.json b/node_modules/libcipm/package.json index f520bd6fbc3db..7aa96e97574c0 100644 --- a/node_modules/libcipm/package.json +++ b/node_modules/libcipm/package.json @@ -1,28 +1,28 @@ { - "_from": "libcipm@4.0.3", - "_id": "libcipm@4.0.3", + "_from": "libcipm@4.0.4", + "_id": "libcipm@4.0.4", "_inBundle": false, - "_integrity": "sha512-nuIxNtqA+kIkwUiNM/nZ0yPyR7NkSUov6g6mCfFPkYylO1dEovZBL+NZ3axdouS2UOTa8GdnJ7/meSc1/0AIGw==", + "_integrity": "sha512-S2hmT4tYXTpq1H98K+gm/fujDcgQKqPz0QwkmtKrGklAo7U0DI9ZYmQq/EahF3sqw33Quv9gMHJGeodqyX23kg==", "_location": "/libcipm", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "libcipm@4.0.3", + "raw": "libcipm@4.0.4", "name": "libcipm", "escapedName": "libcipm", - "rawSpec": "4.0.3", + "rawSpec": "4.0.4", "saveSpec": null, - "fetchSpec": "4.0.3" + "fetchSpec": "4.0.4" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/libcipm/-/libcipm-4.0.3.tgz", - "_shasum": "6a6db4a6e040e56f4af18bb1d664e05e8eb23a39", - "_spec": "libcipm@4.0.3", - "_where": "/Users/isaacs/dev/npm/cli", + "_resolved": "https://registry.npmjs.org/libcipm/-/libcipm-4.0.4.tgz", + "_shasum": "6d28fd0f31e61963f8ec7125e9247349181f6cf4", + "_spec": "libcipm@4.0.4", + "_where": "/Users/mperrotte/npminc/cli", "author": { "name": "Kat Marchán", "email": "kzm@sykosomatic.org" @@ -96,5 +96,5 @@ "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "4.0.3" + "version": "4.0.4" } diff --git a/package-lock.json b/package-lock.json index 026c686e6fef9..f2ab35e24f61b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3060,9 +3060,9 @@ } }, "libcipm": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/libcipm/-/libcipm-4.0.3.tgz", - "integrity": "sha512-nuIxNtqA+kIkwUiNM/nZ0yPyR7NkSUov6g6mCfFPkYylO1dEovZBL+NZ3axdouS2UOTa8GdnJ7/meSc1/0AIGw==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/libcipm/-/libcipm-4.0.4.tgz", + "integrity": "sha512-S2hmT4tYXTpq1H98K+gm/fujDcgQKqPz0QwkmtKrGklAo7U0DI9ZYmQq/EahF3sqw33Quv9gMHJGeodqyX23kg==", "requires": { "bin-links": "^1.1.2", "bluebird": "^3.5.1", diff --git a/package.json b/package.json index 22d3f538ab1aa..e8cfebb459f76 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "is-cidr": "^3.0.0", "json-parse-better-errors": "^1.0.2", "lazy-property": "~1.0.0", - "libcipm": "^4.0.3", + "libcipm": "^4.0.4", "libnpm": "^3.0.1", "libnpmaccess": "^3.0.2", "libnpmhook": "^5.0.3", From 890b245dc1f609590d8ab993fac7cf5a37ed46a5 Mon Sep 17 00:00:00 2001 From: claudiahdz Date: Mon, 16 Sep 2019 12:56:25 +0200 Subject: [PATCH 03/27] chore(ci): add dirPacker to options PR-URL: https://github.com/npm/cli/pull/252 Credit: @claudiahdz Close: #252 Reviewed-by: @mikemimik --- lib/ci.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ci.js b/lib/ci.js index 309ad2f784ec0..a0df3b86ff42b 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -4,6 +4,7 @@ const npm = require('./npm.js') const Installer = require('libcipm') const log = require('npmlog') const path = require('path') +const pack = require('./pack.js') ci.usage = 'npm ci' @@ -27,7 +28,8 @@ function ci (args, cb) { fmode: npm.modes.file, umask: npm.modes.umask, npmVersion: npm.version, - tmp: npm.tmp + tmp: npm.tmp, + dirPacker: pack.packGitDep } for (const key in npm.config.list[0]) { From 7e04f728cc4cd4853a8fc99e2df0a12988897589 Mon Sep 17 00:00:00 2001 From: Michael Perrotte Date: Tue, 24 Sep 2019 15:40:44 -0400 Subject: [PATCH 04/27] tar@4.4.12 --- node_modules/fs-minipass/index.js | 1 + .../node_modules/minipass}/LICENSE | 2 +- .../node_modules/minipass/README.md | 606 ++++++++++++++++++ .../node_modules/minipass/index.js | 518 +++++++++++++++ .../node_modules/minipass/package.json | 70 ++ node_modules/fs-minipass/package.json | 21 +- node_modules/minizlib/index.js | 13 +- node_modules/minizlib/package.json | 12 +- node_modules/tar/lib/parse.js | 7 +- node_modules/tar/lib/read-entry.js | 4 + .../tar/node_modules/minipass/README.md | 490 +++++++++++++- .../tar/node_modules/minipass/index.js | 199 +++++- .../tar/node_modules/minipass/package.json | 31 +- .../tar/node_modules/yallist/README.md | 204 ------ .../tar/node_modules/yallist/iterator.js | 8 - .../tar/node_modules/yallist/package.json | 63 -- .../tar/node_modules/yallist/yallist.js | 376 ----------- node_modules/tar/package.json | 32 +- package-lock.json | 44 +- package.json | 2 +- 20 files changed, 1952 insertions(+), 751 deletions(-) rename node_modules/{tar/node_modules/yallist => fs-minipass/node_modules/minipass}/LICENSE (93%) create mode 100644 node_modules/fs-minipass/node_modules/minipass/README.md create mode 100644 node_modules/fs-minipass/node_modules/minipass/index.js create mode 100644 node_modules/fs-minipass/node_modules/minipass/package.json delete mode 100644 node_modules/tar/node_modules/yallist/README.md delete mode 100644 node_modules/tar/node_modules/yallist/iterator.js delete mode 100644 node_modules/tar/node_modules/yallist/package.json delete mode 100644 node_modules/tar/node_modules/yallist/yallist.js diff --git a/node_modules/fs-minipass/index.js b/node_modules/fs-minipass/index.js index 6bb7f102d8022..cd585a83c59b8 100644 --- a/node_modules/fs-minipass/index.js +++ b/node_modules/fs-minipass/index.js @@ -6,6 +6,7 @@ const fs = require('fs') // for writev const binding = process.binding('fs') const writeBuffers = binding.writeBuffers +/* istanbul ignore next */ const FSReqWrap = binding.FSReqWrap || binding.FSReqCallback const _autoClose = Symbol('_autoClose') diff --git a/node_modules/tar/node_modules/yallist/LICENSE b/node_modules/fs-minipass/node_modules/minipass/LICENSE similarity index 93% rename from node_modules/tar/node_modules/yallist/LICENSE rename to node_modules/fs-minipass/node_modules/minipass/LICENSE index 19129e315fe59..20a4762540923 100644 --- a/node_modules/tar/node_modules/yallist/LICENSE +++ b/node_modules/fs-minipass/node_modules/minipass/LICENSE @@ -1,6 +1,6 @@ The ISC License -Copyright (c) Isaac Z. Schlueter and Contributors +Copyright (c) npm, Inc. and Contributors Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/node_modules/fs-minipass/node_modules/minipass/README.md b/node_modules/fs-minipass/node_modules/minipass/README.md new file mode 100644 index 0000000000000..c989beea0e6d9 --- /dev/null +++ b/node_modules/fs-minipass/node_modules/minipass/README.md @@ -0,0 +1,606 @@ +# minipass + +A _very_ minimal implementation of a [PassThrough +stream](https://nodejs.org/api/stream.html#stream_class_stream_passthrough) + +[It's very +fast](https://docs.google.com/spreadsheets/d/1oObKSrVwLX_7Ut4Z6g3fZW-AX1j1-k6w-cDsrkaSbHM/edit#gid=0) +for objects, strings, and buffers. + +Supports pipe()ing (including multi-pipe() and backpressure +transmission), buffering data until either a `data` event handler or +`pipe()` is added (so you don't lose the first chunk), and most other +cases where PassThrough is a good idea. + +There is a `read()` method, but it's much more efficient to consume +data from this stream via `'data'` events or by calling `pipe()` into +some other stream. Calling `read()` requires the buffer to be +flattened in some cases, which requires copying memory. + +There is also no `unpipe()` method. Once you start piping, there is +no stopping it! + +If you set `objectMode: true` in the options, then whatever is written +will be emitted. Otherwise, it'll do a minimal amount of Buffer +copying to ensure proper Streams semantics when `read(n)` is called. + +`objectMode` can also be set by doing `stream.objectMode = true`, or by +writing any non-string/non-buffer data. `objectMode` cannot be set to +false once it is set. + +This is not a `through` or `through2` stream. It doesn't transform +the data, it just passes it right through. If you want to transform +the data, extend the class, and override the `write()` method. Once +you're done transforming the data however you want, call +`super.write()` with the transform output. + +For some examples of streams that extend Minipass in various ways, check +out: + +- [minizlib](http://npm.im/minizlib) +- [fs-minipass](http://npm.im/fs-minipass) +- [tar](http://npm.im/tar) +- [minipass-collect](http://npm.im/minipass-collect) +- [minipass-flush](http://npm.im/minipass-flush) +- [minipass-pipeline](http://npm.im/minipass-pipeline) +- [tap](http://npm.im/tap) +- [tap-parser](http://npm.im/tap) +- [treport](http://npm.im/tap) + +## Differences from Node.js Streams + +There are several things that make Minipass streams different from (and in +some ways superior to) Node.js core streams. + +Please read these caveats if you are familiar with noode-core streams and +intend to use Minipass streams in your programs. + +### Timing + +Minipass streams are designed to support synchronous use-cases. Thus, data +is emitted as soon as it is available, always. It is buffered until read, +but no longer. Another way to look at it is that Minipass streams are +exactly as synchronous as the logic that writes into them. + +This can be surprising if your code relies on `PassThrough.write()` always +providing data on the next tick rather than the current one, or being able +to call `resume()` and not have the entire buffer disappear immediately. + +However, without this synchronicity guarantee, there would be no way for +Minipass to achieve the speeds it does, or support the synchronous use +cases that it does. Simply put, waiting takes time. + +This non-deferring approach makes Minipass streams much easier to reason +about, especially in the context of Promises and other flow-control +mechanisms. + +### No High/Low Water Marks + +Node.js core streams will optimistically fill up a buffer, returning `true` +on all writes until the limit is hit, even if the data has nowhere to go. +Then, they will not attempt to draw more data in until the buffer size dips +below a minimum value. + +Minipass streams are much simpler. The `write()` method will return `true` +if the data has somewhere to go (which is to say, given the timing +guarantees, that the data is already there by the time `write()` returns). + +If the data has nowhere to go, then `write()` returns false, and the data +sits in a buffer, to be drained out immediately as soon as anyone consumes +it. + +### Hazards of Buffering (or: Why Minipass Is So Fast) + +Since data written to a Minipass stream is immediately written all the way +through the pipeline, and `write()` always returns true/false based on +whether the data was fully flushed, backpressure is communicated +immediately to the upstream caller. This minimizes buffering. + +Consider this case: + +```js +const {PassThrough} = require('stream') +const p1 = new PassThrough({ highWaterMark: 1024 }) +const p2 = new PassThrough({ highWaterMark: 1024 }) +const p3 = new PassThrough({ highWaterMark: 1024 }) +const p4 = new PassThrough({ highWaterMark: 1024 }) + +p1.pipe(p2).pipe(p3).pipe(p4) +p4.on('data', () => console.log('made it through')) + +// this returns false and buffers, then writes to p2 on next tick (1) +// p2 returns false and buffers, pausing p1, then writes to p3 on next tick (2) +// p3 returns false and buffers, pausing p2, then writes to p4 on next tick (3) +// p4 returns false and buffers, pausing p3, then emits 'data' and 'drain' +// on next tick (4) +// p3 sees p4's 'drain' event, and calls resume(), emitting 'resume' and +// 'drain' on next tick (5) +// p2 sees p3's 'drain', calls resume(), emits 'resume' and 'drain' on next tick (6) +// p1 sees p2's 'drain', calls resume(), emits 'resume' and 'drain' on next +// tick (7) + +p1.write(Buffer.alloc(2048)) // returns false +``` + +Along the way, the data was buffered and deferred at each stage, and +multiple event deferrals happened, for an unblocked pipeline where it was +perfectly safe to write all the way through! + +Furthermore, setting a `highWaterMark` of `1024` might lead someone reading +the code to think an advisory maximum of 1KiB is being set for the +pipeline. However, the actual advisory buffering level is the _sum_ of +`highWaterMark` values, since each one has its own bucket. + +Consider the Minipass case: + +```js +const m1 = new Minipass() +const m2 = new Minipass() +const m3 = new Minipass() +const m4 = new Minipass() + +m1.pipe(m2).pipe(m3).pipe(m4) +m4.on('data', () => console.log('made it through')) + +// m1 is flowing, so it writes the data to m2 immediately +// m2 is flowing, so it writes the data to m3 immediately +// m3 is flowing, so it writes the data to m4 immediately +// m4 is flowing, so it fires the 'data' event immediately, returns true +// m4's write returned true, so m3 is still flowing, returns true +// m3's write returned true, so m2 is still flowing, returns true +// m2's write returned true, so m1 is still flowing, returns true +// No event deferrals or buffering along the way! + +m1.write(Buffer.alloc(2048)) // returns true +``` + +It is extremely unlikely that you _don't_ want to buffer any data written, +or _ever_ buffer data that can be flushed all the way through. Neither +node-core streams nor Minipass ever fail to buffer written data, but +node-core streams do a lot of unnecessary buffering and pausing. + +As always, the faster implementation is the one that does less stuff and +waits less time to do it. + +### Immediately emit `end` for empty streams (when not paused) + +If a stream is not paused, and `end()` is called before writing any data +into it, then it will emit `end` immediately. + +If you have logic that occurs on the `end` event which you don't want to +potentially happen immediately (for example, closing file descriptors, +moving on to the next entry in an archive parse stream, etc.) then be sure +to call `stream.pause()` on creation, and then `stream.resume()` once you +are ready to respond to the `end` event. + +### Emit `end` When Asked + +One hazard of immediately emitting `'end'` is that you may not yet have had +a chance to add a listener. In order to avoid this hazard, Minipass +streams safely re-emit the `'end'` event if a new listener is added after +`'end'` has been emitted. + +Ie, if you do `stream.on('end', someFunction)`, and the stream has already +emitted `end`, then it will call the handler right away. (You can think of +this somewhat like attaching a new `.then(fn)` to a previously-resolved +Promise.) + +To prevent calling handlers multiple times who would not expect multiple +ends to occur, all listeners are removed from the `'end'` event whenever it +is emitted. + +### Impact of "immediate flow" on Tee-streams + +A "tee stream" is a stream piping to multiple destinations: + +```js +const tee = new Minipass() +t.pipe(dest1) +t.pipe(dest2) +t.write('foo') // goes to both destinations +``` + +Since Minipass streams _immediately_ process any pending data through the +pipeline when a new pipe destination is added, this can have surprising +effects, especially when a stream comes in from some other function and may +or may not have data in its buffer. + +```js +// WARNING! WILL LOSE DATA! +const src = new Minipass() +src.write('foo') +src.pipe(dest1) // 'foo' chunk flows to dest1 immediately, and is gone +src.pipe(dest2) // gets nothing! +``` + +The solution is to create a dedicated tee-stream junction that pipes to +both locations, and then pipe to _that_ instead. + +```js +// Safe example: tee to both places +const src = new Minipass() +src.write('foo') +const tee = new Minipass() +tee.pipe(dest1) +tee.pipe(dest2) +stream.pipe(tee) // tee gets 'foo', pipes to both locations +``` + +The same caveat applies to `on('data')` event listeners. The first one +added will _immediately_ receive all of the data, leaving nothing for the +second: + +```js +// WARNING! WILL LOSE DATA! +const src = new Minipass() +src.write('foo') +src.on('data', handler1) // receives 'foo' right away +src.on('data', handler2) // nothing to see here! +``` + +Using a dedicated tee-stream can be used in this case as well: + +```js +// Safe example: tee to both data handlers +const src = new Minipass() +src.write('foo') +const tee = new Minipass() +tee.on('data', handler1) +tee.on('data', handler2) +src.pipe(tee) +``` + +## USAGE + +It's a stream! Use it like a stream and it'll most likely do what you want. + +```js +const Minipass = require('minipass') +const mp = new Minipass(options) // optional: { encoding, objectMode } +mp.write('foo') +mp.pipe(someOtherStream) +mp.end('bar') +``` + +### OPTIONS + +* `encoding` How would you like the data coming _out_ of the stream to be + encoded? Accepts any values that can be passed to `Buffer.toString()`. +* `objectMode` Emit data exactly as it comes in. This will be flipped on + by default if you write() something other than a string or Buffer at any + point. Setting `objectMode: true` will prevent setting any encoding + value. + +### API + +Implements the user-facing portions of Node.js's `Readable` and `Writable` +streams. + +### Methods + +* `write(chunk, [encoding], [callback])` - Put data in. (Note that, in the + base Minipass class, the same data will come out.) Returns `false` if + the stream will buffer the next write, or true if it's still in + "flowing" mode. +* `end([chunk, [encoding]], [callback])` - Signal that you have no more + data to write. This will queue an `end` event to be fired when all the + data has been consumed. +* `setEncoding(encoding)` - Set the encoding for data coming of the + stream. This can only be done once. +* `pause()` - No more data for a while, please. This also prevents `end` + from being emitted for empty streams until the stream is resumed. +* `resume()` - Resume the stream. If there's data in the buffer, it is + all discarded. Any buffered events are immediately emitted. +* `pipe(dest)` - Send all output to the stream provided. There is no way + to unpipe. When data is emitted, it is immediately written to any and + all pipe destinations. +* `on(ev, fn)`, `emit(ev, fn)` - Minipass streams are EventEmitters. + Some events are given special treatment, however. (See below under + "events".) +* `promise()` - Returns a Promise that resolves when the stream emits + `end`, or rejects if the stream emits `error`. +* `collect()` - Return a Promise that resolves on `end` with an array + containing each chunk of data that was emitted, or rejects if the + stream emits `error`. Note that this consumes the stream data. +* `concat()` - Same as `collect()`, but concatenates the data into a + single Buffer object. Will reject the returned promise if the stream is + in objectMode, or if it goes into objectMode by the end of the data. +* `read(n)` - Consume `n` bytes of data out of the buffer. If `n` is not + provided, then consume all of it. If `n` bytes are not available, then + it returns null. **Note** consuming streams in this way is less + efficient, and can lead to unnecessary Buffer copying. +* `destroy([er])` - Destroy the stream. If an error is provided, then an + `'error'` event is emitted. If the stream has a `close()` method, and + has not emitted a `'close'` event yet, then `stream.close()` will be + called. Any Promises returned by `.promise()`, `.collect()` or + `.concat()` will be rejected. After being destroyed, writing to the + stream will emit an error. No more data will be emitted if the stream is + destroyed, even if it was previously buffered. + +### Properties + +* `bufferLength` Read-only. Total number of bytes buffered, or in the case + of objectMode, the total number of objects. +* `encoding` The encoding that has been set. (Setting this is equivalent + to calling `setEncoding(enc)` and has the same prohibition against + setting multiple times.) +* `flowing` Read-only. Boolean indicating whether a chunk written to the + stream will be immediately emitted. +* `emittedEnd` Read-only. Boolean indicating whether the end-ish events + (ie, `end`, `prefinish`, `finish`) have been emitted. Note that + listening on any end-ish event will immediateyl re-emit it if it has + already been emitted. +* `writable` Whether the stream is writable. Default `true`. Set to + `false` when `end()` +* `readable` Whether the stream is readable. Default `true`. +* `buffer` A [yallist](http://npm.im/yallist) linked list of chunks written + to the stream that have not yet been emitted. (It's probably a bad idea + to mess with this.) +* `pipes` A [yallist](http://npm.im/yallist) linked list of streams that + this stream is piping into. (It's probably a bad idea to mess with + this.) +* `destroyed` A getter that indicates whether the stream was destroyed. +* `paused` True if the stream has been explicitly paused, otherwise false. +* `objectMode` Indicates whether the stream is in `objectMode`. Once set + to `true`, it cannot be set to `false`. + +### Events + +* `data` Emitted when there's data to read. Argument is the data to read. + This is never emitted while not flowing. If a listener is attached, that + will resume the stream. +* `end` Emitted when there's no more data to read. This will be emitted + immediately for empty streams when `end()` is called. If a listener is + attached, and `end` was already emitted, then it will be emitted again. + All listeners are removed when `end` is emitted. +* `prefinish` An end-ish event that follows the same logic as `end` and is + emitted in the same conditions where `end` is emitted. Emitted after + `'end'`. +* `finish` An end-ish event that follows the same logic as `end` and is + emitted in the same conditions where `end` is emitted. Emitted after + `'prefinish'`. +* `close` An indication that an underlying resource has been released. + Minipass does not emit this event, but will defer it until after `end` + has been emitted, since it throws off some stream libraries otherwise. +* `drain` Emitted when the internal buffer empties, and it is again + suitable to `write()` into the stream. +* `readable` Emitted when data is buffered and ready to be read by a + consumer. +* `resume` Emitted when stream changes state from buffering to flowing + mode. (Ie, when `resume` is called, `pipe` is called, or a `data` event + listener is added.) + +### Static Methods + +* `Minipass.isStream(stream)` Returns `true` if the argument is a stream, + and false otherwise. To be considered a stream, the object must be + either an instance of Minipass, or an EventEmitter that has either a + `pipe()` method, or both `write()` and `end()` methods. (Pretty much any + stream in node-land will return `true` for this.) + +## EXAMPLES + +Here are some examples of things you can do with Minipass streams. + +### simple "are you done yet" promise + +```js +mp.promise().then(() => { + // stream is finished +}, er => { + // stream emitted an error +}) +``` + +### collecting + +```js +mp.collect().then(all => { + // all is an array of all the data emitted + // encoding is supported in this case, so + // so the result will be a collection of strings if + // an encoding is specified, or buffers/objects if not. + // + // In an async function, you may do + // const data = await stream.collect() +}) +``` + +### collecting into a single blob + +This is a bit slower because it concatenates the data into one chunk for +you, but if you're going to do it yourself anyway, it's convenient this +way: + +```js +mp.concat().then(onebigchunk => { + // onebigchunk is a string if the stream + // had an encoding set, or a buffer otherwise. +}) +``` + +### iteration + +You can iterate over streams synchronously or asynchronously in +platforms that support it. + +Synchronous iteration will end when the currently available data is +consumed, even if the `end` event has not been reached. In string and +buffer mode, the data is concatenated, so unless multiple writes are +occurring in the same tick as the `read()`, sync iteration loops will +generally only have a single iteration. + +To consume chunks in this way exactly as they have been written, with +no flattening, create the stream with the `{ objectMode: true }` +option. + +```js +const mp = new Minipass({ objectMode: true }) +mp.write('a') +mp.write('b') +for (let letter of mp) { + console.log(letter) // a, b +} +mp.write('c') +mp.write('d') +for (let letter of mp) { + console.log(letter) // c, d +} +mp.write('e') +mp.end() +for (let letter of mp) { + console.log(letter) // e +} +for (let letter of mp) { + console.log(letter) // nothing +} +``` + +Asynchronous iteration will continue until the end event is reached, +consuming all of the data. + +```js +const mp = new Minipass({ encoding: 'utf8' }) + +// some source of some data +let i = 5 +const inter = setInterval(() => { + if (i --> 0) + mp.write(Buffer.from('foo\n', 'utf8')) + else { + mp.end() + clearInterval(inter) + } +}, 100) + +// consume the data with asynchronous iteration +async function consume () { + for await (let chunk of mp) { + console.log(chunk) + } + return 'ok' +} + +consume().then(res => console.log(res)) +// logs `foo\n` 5 times, and then `ok` +``` + +### subclass that `console.log()`s everything written into it + +```js +class Logger extends Minipass { + write (chunk, encoding, callback) { + console.log('WRITE', chunk, encoding) + return super.write(chunk, encoding, callback) + } + end (chunk, encoding, callback) { + console.log('END', chunk, encoding) + return super.end(chunk, encoding, callback) + } +} + +someSource.pipe(new Logger()).pipe(someDest) +``` + +### same thing, but using an inline anonymous class + +```js +// js classes are fun +someSource + .pipe(new (class extends Minipass { + emit (ev, ...data) { + // let's also log events, because debugging some weird thing + console.log('EMIT', ev) + return super.emit(ev, ...data) + } + write (chunk, encoding, callback) { + console.log('WRITE', chunk, encoding) + return super.write(chunk, encoding, callback) + } + end (chunk, encoding, callback) { + console.log('END', chunk, encoding) + return super.end(chunk, encoding, callback) + } + })) + .pipe(someDest) +``` + +### subclass that defers 'end' for some reason + +```js +class SlowEnd extends Minipass { + emit (ev, ...args) { + if (ev === 'end') { + console.log('going to end, hold on a sec') + setTimeout(() => { + console.log('ok, ready to end now') + super.emit('end', ...args) + }, 100) + } else { + return super.emit(ev, ...args) + } + } +} +``` + +### transform that creates newline-delimited JSON + +```js +class NDJSONEncode extends Minipass { + write (obj, cb) { + try { + // JSON.stringify can throw, emit an error on that + return super.write(JSON.stringify(obj) + '\n', 'utf8', cb) + } catch (er) { + this.emit('error', er) + } + } + end (obj, cb) { + if (typeof obj === 'function') { + cb = obj + obj = undefined + } + if (obj !== undefined) { + this.write(obj) + } + return super.end(cb) + } +} +``` + +### transform that parses newline-delimited JSON + +```js +class NDJSONDecode extends Minipass { + constructor (options) { + // always be in object mode, as far as Minipass is concerned + super({ objectMode: true }) + this._jsonBuffer = '' + } + write (chunk, encoding, cb) { + if (typeof chunk === 'string' && + typeof encoding === 'string' && + encoding !== 'utf8') { + chunk = Buffer.from(chunk, encoding).toString() + } else if (Buffer.isBuffer(chunk)) + chunk = chunk.toString() + } + if (typeof encoding === 'function') { + cb = encoding + } + const jsonData = (this._jsonBuffer + chunk).split('\n') + this._jsonBuffer = jsonData.pop() + for (let i = 0; i < jsonData.length; i++) { + let parsed + try { + super.write(parsed) + } catch (er) { + this.emit('error', er) + continue + } + } + if (cb) + cb() + } +} +``` diff --git a/node_modules/fs-minipass/node_modules/minipass/index.js b/node_modules/fs-minipass/node_modules/minipass/index.js new file mode 100644 index 0000000000000..cab9009f2befb --- /dev/null +++ b/node_modules/fs-minipass/node_modules/minipass/index.js @@ -0,0 +1,518 @@ +'use strict' +const EE = require('events') +const Yallist = require('yallist') +const SD = require('string_decoder').StringDecoder + +const EOF = Symbol('EOF') +const MAYBE_EMIT_END = Symbol('maybeEmitEnd') +const EMITTED_END = Symbol('emittedEnd') +const EMITTING_END = Symbol('emittingEnd') +const CLOSED = Symbol('closed') +const READ = Symbol('read') +const FLUSH = Symbol('flush') +const FLUSHCHUNK = Symbol('flushChunk') +const ENCODING = Symbol('encoding') +const DECODER = Symbol('decoder') +const FLOWING = Symbol('flowing') +const PAUSED = Symbol('paused') +const RESUME = Symbol('resume') +const BUFFERLENGTH = Symbol('bufferLength') +const BUFFERPUSH = Symbol('bufferPush') +const BUFFERSHIFT = Symbol('bufferShift') +const OBJECTMODE = Symbol('objectMode') +const DESTROYED = Symbol('destroyed') + +// TODO remove when Node v8 support drops +const doIter = global._MP_NO_ITERATOR_SYMBOLS_ !== '1' +const ASYNCITERATOR = doIter && Symbol.asyncIterator + || Symbol('asyncIterator not implemented') +const ITERATOR = doIter && Symbol.iterator + || Symbol('iterator not implemented') + +// Buffer in node 4.x < 4.5.0 doesn't have working Buffer.from +// or Buffer.alloc, and Buffer in node 10 deprecated the ctor. +// .M, this is fine .\^/M.. +const B = Buffer.alloc ? Buffer + : /* istanbul ignore next */ require('safe-buffer').Buffer + +// events that mean 'the stream is over' +// these are treated specially, and re-emitted +// if they are listened for after emitting. +const isEndish = ev => + ev === 'end' || + ev === 'finish' || + ev === 'prefinish' + +module.exports = class Minipass extends EE { + constructor (options) { + super() + this[FLOWING] = false + // whether we're explicitly paused + this[PAUSED] = false + this.pipes = new Yallist() + this.buffer = new Yallist() + this[OBJECTMODE] = options && options.objectMode || false + if (this[OBJECTMODE]) + this[ENCODING] = null + else + this[ENCODING] = options && options.encoding || null + if (this[ENCODING] === 'buffer') + this[ENCODING] = null + this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null + this[EOF] = false + this[EMITTED_END] = false + this[EMITTING_END] = false + this[CLOSED] = false + this.writable = true + this.readable = true + this[BUFFERLENGTH] = 0 + this[DESTROYED] = false + } + + get bufferLength () { return this[BUFFERLENGTH] } + + get encoding () { return this[ENCODING] } + set encoding (enc) { + if (this[OBJECTMODE]) + throw new Error('cannot set encoding in objectMode') + + if (this[ENCODING] && enc !== this[ENCODING] && + (this[DECODER] && this[DECODER].lastNeed || this[BUFFERLENGTH])) + throw new Error('cannot change encoding') + + if (this[ENCODING] !== enc) { + this[DECODER] = enc ? new SD(enc) : null + if (this.buffer.length) + this.buffer = this.buffer.map(chunk => this[DECODER].write(chunk)) + } + + this[ENCODING] = enc + } + + setEncoding (enc) { + this.encoding = enc + } + + get objectMode () { return this[OBJECTMODE] } + set objectMode (ॐ ) { this[OBJECTMODE] = this[OBJECTMODE] || !!ॐ } + + write (chunk, encoding, cb) { + if (this[EOF]) + throw new Error('write after end') + + if (this[DESTROYED]) { + this.emit('error', Object.assign( + new Error('Cannot call write after a stream was destroyed'), + { code: 'ERR_STREAM_DESTROYED' } + )) + return true + } + + if (typeof encoding === 'function') + cb = encoding, encoding = 'utf8' + + if (!encoding) + encoding = 'utf8' + + if (typeof chunk !== 'string' && !B.isBuffer(chunk) && !this[OBJECTMODE]) + this.objectMode = true + + // this ensures at this point that the chunk is a buffer or string + // don't buffer it up or send it to the decoder + if (!this.objectMode && !chunk.length) { + const ret = this.flowing + if (this[BUFFERLENGTH] !== 0) + this.emit('readable') + if (cb) + cb() + return ret + } + + // fast-path writing strings of same encoding to a stream with + // an empty buffer, skipping the buffer/decoder dance + if (typeof chunk === 'string' && !this[OBJECTMODE] && + // unless it is a string already ready for us to use + !(encoding === this[ENCODING] && !this[DECODER].lastNeed)) { + chunk = B.from(chunk, encoding) + } + + if (B.isBuffer(chunk) && this[ENCODING]) + chunk = this[DECODER].write(chunk) + + try { + return this.flowing + ? (this.emit('data', chunk), this.flowing) + : (this[BUFFERPUSH](chunk), false) + } finally { + if (this[BUFFERLENGTH] !== 0) + this.emit('readable') + if (cb) + cb() + } + } + + read (n) { + if (this[DESTROYED]) + return null + + try { + if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH]) + return null + + if (this[OBJECTMODE]) + n = null + + if (this.buffer.length > 1 && !this[OBJECTMODE]) { + if (this.encoding) + this.buffer = new Yallist([ + Array.from(this.buffer).join('') + ]) + else + this.buffer = new Yallist([ + B.concat(Array.from(this.buffer), this[BUFFERLENGTH]) + ]) + } + + return this[READ](n || null, this.buffer.head.value) + } finally { + this[MAYBE_EMIT_END]() + } + } + + [READ] (n, chunk) { + if (n === chunk.length || n === null) + this[BUFFERSHIFT]() + else { + this.buffer.head.value = chunk.slice(n) + chunk = chunk.slice(0, n) + this[BUFFERLENGTH] -= n + } + + this.emit('data', chunk) + + if (!this.buffer.length && !this[EOF]) + this.emit('drain') + + return chunk + } + + end (chunk, encoding, cb) { + if (typeof chunk === 'function') + cb = chunk, chunk = null + if (typeof encoding === 'function') + cb = encoding, encoding = 'utf8' + if (chunk) + this.write(chunk, encoding) + if (cb) + this.once('end', cb) + this[EOF] = true + this.writable = false + + // if we haven't written anything, then go ahead and emit, + // even if we're not reading. + // we'll re-emit if a new 'end' listener is added anyway. + // This makes MP more suitable to write-only use cases. + if (this.flowing || !this[PAUSED]) + this[MAYBE_EMIT_END]() + return this + } + + // don't let the internal resume be overwritten + [RESUME] () { + if (this[DESTROYED]) + return + + this[PAUSED] = false + this[FLOWING] = true + this.emit('resume') + if (this.buffer.length) + this[FLUSH]() + else if (this[EOF]) + this[MAYBE_EMIT_END]() + else + this.emit('drain') + } + + resume () { + return this[RESUME]() + } + + pause () { + this[FLOWING] = false + this[PAUSED] = true + } + + get destroyed () { + return this[DESTROYED] + } + + get flowing () { + return this[FLOWING] + } + + get paused () { + return this[PAUSED] + } + + [BUFFERPUSH] (chunk) { + if (this[OBJECTMODE]) + this[BUFFERLENGTH] += 1 + else + this[BUFFERLENGTH] += chunk.length + return this.buffer.push(chunk) + } + + [BUFFERSHIFT] () { + if (this.buffer.length) { + if (this[OBJECTMODE]) + this[BUFFERLENGTH] -= 1 + else + this[BUFFERLENGTH] -= this.buffer.head.value.length + } + return this.buffer.shift() + } + + [FLUSH] () { + do {} while (this[FLUSHCHUNK](this[BUFFERSHIFT]())) + + if (!this.buffer.length && !this[EOF]) + this.emit('drain') + } + + [FLUSHCHUNK] (chunk) { + return chunk ? (this.emit('data', chunk), this.flowing) : false + } + + pipe (dest, opts) { + if (this[DESTROYED]) + return + + const ended = this[EMITTED_END] + opts = opts || {} + if (dest === process.stdout || dest === process.stderr) + opts.end = false + else + opts.end = opts.end !== false + + const p = { dest: dest, opts: opts, ondrain: _ => this[RESUME]() } + this.pipes.push(p) + + dest.on('drain', p.ondrain) + this[RESUME]() + // piping an ended stream ends immediately + if (ended && p.opts.end) + p.dest.end() + return dest + } + + addListener (ev, fn) { + return this.on(ev, fn) + } + + on (ev, fn) { + try { + return super.on(ev, fn) + } finally { + if (ev === 'data' && !this.pipes.length && !this.flowing) + this[RESUME]() + else if (isEndish(ev) && this[EMITTED_END]) { + super.emit(ev) + this.removeAllListeners(ev) + } + } + } + + get emittedEnd () { + return this[EMITTED_END] + } + + [MAYBE_EMIT_END] () { + if (!this[EMITTING_END] && + !this[EMITTED_END] && + !this[DESTROYED] && + this.buffer.length === 0 && + this[EOF]) { + this[EMITTING_END] = true + this.emit('end') + this.emit('prefinish') + this.emit('finish') + if (this[CLOSED]) + this.emit('close') + this[EMITTING_END] = false + } + } + + emit (ev, data) { + // error and close are only events allowed after calling destroy() + if (ev !== 'error' && ev !== 'close' && ev !== DESTROYED && this[DESTROYED]) + return + else if (ev === 'data') { + if (!data) + return + + if (this.pipes.length) + this.pipes.forEach(p => + p.dest.write(data) === false && this.pause()) + } else if (ev === 'end') { + // only actual end gets this treatment + if (this[EMITTED_END] === true) + return + + this[EMITTED_END] = true + this.readable = false + + if (this[DECODER]) { + data = this[DECODER].end() + if (data) { + this.pipes.forEach(p => p.dest.write(data)) + super.emit('data', data) + } + } + + this.pipes.forEach(p => { + p.dest.removeListener('drain', p.ondrain) + if (p.opts.end) + p.dest.end() + }) + } else if (ev === 'close') { + this[CLOSED] = true + // don't emit close before 'end' and 'finish' + if (!this[EMITTED_END] && !this[DESTROYED]) + return + } + + // TODO: replace with a spread operator when Node v4 support drops + const args = new Array(arguments.length) + args[0] = ev + args[1] = data + if (arguments.length > 2) { + for (let i = 2; i < arguments.length; i++) { + args[i] = arguments[i] + } + } + + try { + return super.emit.apply(this, args) + } finally { + if (!isEndish(ev)) + this[MAYBE_EMIT_END]() + else + this.removeAllListeners(ev) + } + } + + // const all = await stream.collect() + collect () { + const buf = [] + buf.dataLength = 0 + this.on('data', c => { + buf.push(c) + buf.dataLength += c.length + }) + return this.promise().then(() => buf) + } + + // const data = await stream.concat() + concat () { + return this[OBJECTMODE] + ? Promise.reject(new Error('cannot concat in objectMode')) + : this.collect().then(buf => + this[OBJECTMODE] + ? Promise.reject(new Error('cannot concat in objectMode')) + : this[ENCODING] ? buf.join('') : B.concat(buf, buf.dataLength)) + } + + // stream.promise().then(() => done, er => emitted error) + promise () { + return new Promise((resolve, reject) => { + this.on(DESTROYED, () => reject(new Error('stream destroyed'))) + this.on('end', () => resolve()) + this.on('error', er => reject(er)) + }) + } + + // for await (let chunk of stream) + [ASYNCITERATOR] () { + const next = () => { + const res = this.read() + if (res !== null) + return Promise.resolve({ done: false, value: res }) + + if (this[EOF]) + return Promise.resolve({ done: true }) + + let resolve = null + let reject = null + const onerr = er => { + this.removeListener('data', ondata) + this.removeListener('end', onend) + reject(er) + } + const ondata = value => { + this.removeListener('error', onerr) + this.removeListener('end', onend) + this.pause() + resolve({ value: value, done: !!this[EOF] }) + } + const onend = () => { + this.removeListener('error', onerr) + this.removeListener('data', ondata) + resolve({ done: true }) + } + const ondestroy = () => onerr(new Error('stream destroyed')) + return new Promise((res, rej) => { + reject = rej + resolve = res + this.once(DESTROYED, ondestroy) + this.once('error', onerr) + this.once('end', onend) + this.once('data', ondata) + }) + } + + return { next } + } + + // for (let chunk of stream) + [ITERATOR] () { + const next = () => { + const value = this.read() + const done = value === null + return { value, done } + } + return { next } + } + + destroy (er) { + if (this[DESTROYED]) { + if (er) + this.emit('error', er) + else + this.emit(DESTROYED) + return this + } + + this[DESTROYED] = true + + // throw away all buffered data, it's never coming out + this.buffer = new Yallist() + this[BUFFERLENGTH] = 0 + + if (typeof this.close === 'function' && !this[CLOSED]) + this.close() + + if (er) + this.emit('error', er) + else // if no error to emit, still reject pending promises + this.emit(DESTROYED) + + return this + } + + static isStream (s) { + return !!s && (s instanceof Minipass || s instanceof EE && ( + typeof s.pipe === 'function' || // readable + (typeof s.write === 'function' && typeof s.end === 'function') // writable + )) + } +} diff --git a/node_modules/fs-minipass/node_modules/minipass/package.json b/node_modules/fs-minipass/node_modules/minipass/package.json new file mode 100644 index 0000000000000..f2b601937c4c4 --- /dev/null +++ b/node_modules/fs-minipass/node_modules/minipass/package.json @@ -0,0 +1,70 @@ +{ + "_from": "minipass@^2.6.0", + "_id": "minipass@2.8.6", + "_inBundle": false, + "_integrity": "sha512-lFG7d6g3+/UaFDCOtqPiKAC9zngWWsQZl1g5q6gaONqrjq61SX2xFqXMleQiFVyDpYwa018E9hmlAFY22PCb+A==", + "_location": "/fs-minipass/minipass", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "minipass@^2.6.0", + "name": "minipass", + "escapedName": "minipass", + "rawSpec": "^2.6.0", + "saveSpec": null, + "fetchSpec": "^2.6.0" + }, + "_requiredBy": [ + "/fs-minipass" + ], + "_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.8.6.tgz", + "_shasum": "620d889ace26356391d010ecb9458749df9b6db5", + "_spec": "minipass@^2.6.0", + "_where": "/Users/mperrotte/npminc/cli/node_modules/fs-minipass", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/minipass/issues" + }, + "bundleDependencies": false, + "dependencies": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + }, + "deprecated": false, + "description": "minimal implementation of a PassThrough stream", + "devDependencies": { + "end-of-stream": "^1.4.0", + "tap": "^14.6.4", + "through2": "^2.0.3" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/isaacs/minipass#readme", + "keywords": [ + "passthrough", + "stream" + ], + "license": "ISC", + "main": "index.js", + "name": "minipass", + "repository": { + "type": "git", + "url": "git+https://github.com/isaacs/minipass.git" + }, + "scripts": { + "postpublish": "git push origin --follow-tags", + "postversion": "npm publish", + "preversion": "npm test", + "test": "tap" + }, + "tap": { + "check-coverage": true + }, + "version": "2.8.6" +} diff --git a/node_modules/fs-minipass/package.json b/node_modules/fs-minipass/package.json index dd3186653953b..870d08f6fb963 100644 --- a/node_modules/fs-minipass/package.json +++ b/node_modules/fs-minipass/package.json @@ -1,10 +1,13 @@ { "_from": "fs-minipass@^1.2.5", - "_id": "fs-minipass@1.2.6", + "_id": "fs-minipass@1.2.7", "_inBundle": false, - "_integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", + "_integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", "_location": "/fs-minipass", - "_phantomChildren": {}, + "_phantomChildren": { + "safe-buffer": "5.1.2", + "yallist": "3.0.3" + }, "_requested": { "type": "range", "registry": true, @@ -18,10 +21,10 @@ "_requiredBy": [ "/tar" ], - "_resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", - "_shasum": "2c5cc30ded81282bfe8a0d7c7c1853ddeb102c07", + "_resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "_shasum": "ccff8570841e7fe4265693da88936c55aed7f7c7", "_spec": "fs-minipass@^1.2.5", - "_where": "/Users/isaacs/dev/npm/cli/node_modules/tar", + "_where": "/Users/mperrotte/npminc/cli/node_modules/tar", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -32,13 +35,13 @@ }, "bundleDependencies": false, "dependencies": { - "minipass": "^2.2.1" + "minipass": "^2.6.0" }, "deprecated": false, "description": "fs read and write streams based on minipass", "devDependencies": { "mutate-fs": "^2.0.1", - "tap": "^13.1.9" + "tap": "^14.6.4" }, "files": [ "index.js" @@ -61,5 +64,5 @@ "tap": { "check-coverage": true }, - "version": "1.2.6" + "version": "1.2.7" } diff --git a/node_modules/minizlib/index.js b/node_modules/minizlib/index.js index df486965c7e82..1385dc2363c02 100644 --- a/node_modules/minizlib/index.js +++ b/node_modules/minizlib/index.js @@ -60,6 +60,7 @@ const _flushFlag = Symbol('flushFlag') const _finishFlush = Symbol('finishFlush') const _handle = Symbol('handle') const _onError = Symbol('onError') +const _sawError = Symbol('sawError') const _level = Symbol('level') const _strategy = Symbol('strategy') const _ended = Symbol('ended') @@ -119,6 +120,7 @@ class Zlib extends MiniPass { this[_handle] = new realZlib[mode](opts) this[_onError] = (err) => { + this[_sawError] = true // there is no way to cleanly recover. // continuing only obscures problems. this.close() @@ -152,6 +154,9 @@ class Zlib extends MiniPass { } params (level, strategy) { + if (this[_sawError]) + return + if (!this[_handle]) throw new Error('cannot switch params when binding is closed') @@ -190,8 +195,10 @@ class Zlib extends MiniPass { } reset () { - assert(this[_handle], 'zlib binding closed') - return this[_handle].reset() + if (!this[_sawError]) { + assert(this[_handle], 'zlib binding closed') + return this[_handle].reset() + } } flush (kind) { @@ -228,6 +235,8 @@ class Zlib extends MiniPass { if (typeof chunk === 'string') chunk = Buffer.from(chunk, encoding) + if (this[_sawError]) + return assert(this[_handle], 'zlib binding closed') // _processChunk tries to .close() the native handle after it's done, so we diff --git a/node_modules/minizlib/package.json b/node_modules/minizlib/package.json index 0e6e4f4670752..fbf08b3df98c1 100644 --- a/node_modules/minizlib/package.json +++ b/node_modules/minizlib/package.json @@ -1,8 +1,8 @@ { "_from": "minizlib@^1.2.1", - "_id": "minizlib@1.2.1", + "_id": "minizlib@1.2.2", "_inBundle": false, - "_integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "_integrity": "sha512-hR3At21uSrsjjDTWrbu0IMLTpnkpv8IIMFDFaoz43Tmu4LkmAXfH44vNNzpTnf+OAQQCHrb91y/wc2J4x5XgSQ==", "_location": "/minizlib", "_phantomChildren": {}, "_requested": { @@ -18,10 +18,10 @@ "_requiredBy": [ "/tar" ], - "_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "_shasum": "dd27ea6136243c7c880684e8672bb3a45fd9b614", + "_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.2.tgz", + "_shasum": "6f0ccc82fa53e1bf2ff145f220d2da9fa6e3a166", "_spec": "minizlib@^1.2.1", - "_where": "/Users/isaacs/dev/npm/cli/node_modules/tar", + "_where": "/Users/mperrotte/npminc/cli/node_modules/tar", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -67,5 +67,5 @@ "preversion": "npm test", "test": "tap test/*.js --100 -J" }, - "version": "1.2.1" + "version": "1.2.2" } diff --git a/node_modules/tar/lib/parse.js b/node_modules/tar/lib/parse.js index 34e3cd70c2fe9..43d4383ddaf89 100644 --- a/node_modules/tar/lib/parse.js +++ b/node_modules/tar/lib/parse.js @@ -102,7 +102,12 @@ module.exports = warner(class Parser extends EE { } [CONSUMEHEADER] (chunk, position) { - const header = new Header(chunk, position, this[EX], this[GEX]) + let header + try { + header = new Header(chunk, position, this[EX], this[GEX]) + } catch (er) { + return this.warn('invalid entry', er) + } if (header.nullBlock) this[EMIT]('nullBlock') diff --git a/node_modules/tar/lib/read-entry.js b/node_modules/tar/lib/read-entry.js index aa369c74f5b02..8acee94baced5 100644 --- a/node_modules/tar/lib/read-entry.js +++ b/node_modules/tar/lib/read-entry.js @@ -6,6 +6,10 @@ const SLURP = Symbol('slurp') module.exports = class ReadEntry extends MiniPass { constructor (header, ex, gex) { super() + // read entries always start life paused. this is to avoid the + // situation where Minipass's auto-ending empty streams results + // in an entry ending before we're ready for it. + this.pause() this.extended = ex this.globalExtended = gex this.header = header diff --git a/node_modules/tar/node_modules/minipass/README.md b/node_modules/tar/node_modules/minipass/README.md index 7a83c59ffd709..c989beea0e6d9 100644 --- a/node_modules/tar/node_modules/minipass/README.md +++ b/node_modules/tar/node_modules/minipass/README.md @@ -24,25 +24,374 @@ If you set `objectMode: true` in the options, then whatever is written will be emitted. Otherwise, it'll do a minimal amount of Buffer copying to ensure proper Streams semantics when `read(n)` is called. +`objectMode` can also be set by doing `stream.objectMode = true`, or by +writing any non-string/non-buffer data. `objectMode` cannot be set to +false once it is set. + This is not a `through` or `through2` stream. It doesn't transform the data, it just passes it right through. If you want to transform the data, extend the class, and override the `write()` method. Once you're done transforming the data however you want, call `super.write()` with the transform output. -For an example of a stream that extends MiniPass to provide transform -capabilities, check out [minizlib](http://npm.im/minizlib). +For some examples of streams that extend Minipass in various ways, check +out: + +- [minizlib](http://npm.im/minizlib) +- [fs-minipass](http://npm.im/fs-minipass) +- [tar](http://npm.im/tar) +- [minipass-collect](http://npm.im/minipass-collect) +- [minipass-flush](http://npm.im/minipass-flush) +- [minipass-pipeline](http://npm.im/minipass-pipeline) +- [tap](http://npm.im/tap) +- [tap-parser](http://npm.im/tap) +- [treport](http://npm.im/tap) + +## Differences from Node.js Streams + +There are several things that make Minipass streams different from (and in +some ways superior to) Node.js core streams. + +Please read these caveats if you are familiar with noode-core streams and +intend to use Minipass streams in your programs. + +### Timing + +Minipass streams are designed to support synchronous use-cases. Thus, data +is emitted as soon as it is available, always. It is buffered until read, +but no longer. Another way to look at it is that Minipass streams are +exactly as synchronous as the logic that writes into them. + +This can be surprising if your code relies on `PassThrough.write()` always +providing data on the next tick rather than the current one, or being able +to call `resume()` and not have the entire buffer disappear immediately. + +However, without this synchronicity guarantee, there would be no way for +Minipass to achieve the speeds it does, or support the synchronous use +cases that it does. Simply put, waiting takes time. + +This non-deferring approach makes Minipass streams much easier to reason +about, especially in the context of Promises and other flow-control +mechanisms. + +### No High/Low Water Marks + +Node.js core streams will optimistically fill up a buffer, returning `true` +on all writes until the limit is hit, even if the data has nowhere to go. +Then, they will not attempt to draw more data in until the buffer size dips +below a minimum value. + +Minipass streams are much simpler. The `write()` method will return `true` +if the data has somewhere to go (which is to say, given the timing +guarantees, that the data is already there by the time `write()` returns). + +If the data has nowhere to go, then `write()` returns false, and the data +sits in a buffer, to be drained out immediately as soon as anyone consumes +it. + +### Hazards of Buffering (or: Why Minipass Is So Fast) + +Since data written to a Minipass stream is immediately written all the way +through the pipeline, and `write()` always returns true/false based on +whether the data was fully flushed, backpressure is communicated +immediately to the upstream caller. This minimizes buffering. + +Consider this case: + +```js +const {PassThrough} = require('stream') +const p1 = new PassThrough({ highWaterMark: 1024 }) +const p2 = new PassThrough({ highWaterMark: 1024 }) +const p3 = new PassThrough({ highWaterMark: 1024 }) +const p4 = new PassThrough({ highWaterMark: 1024 }) + +p1.pipe(p2).pipe(p3).pipe(p4) +p4.on('data', () => console.log('made it through')) + +// this returns false and buffers, then writes to p2 on next tick (1) +// p2 returns false and buffers, pausing p1, then writes to p3 on next tick (2) +// p3 returns false and buffers, pausing p2, then writes to p4 on next tick (3) +// p4 returns false and buffers, pausing p3, then emits 'data' and 'drain' +// on next tick (4) +// p3 sees p4's 'drain' event, and calls resume(), emitting 'resume' and +// 'drain' on next tick (5) +// p2 sees p3's 'drain', calls resume(), emits 'resume' and 'drain' on next tick (6) +// p1 sees p2's 'drain', calls resume(), emits 'resume' and 'drain' on next +// tick (7) + +p1.write(Buffer.alloc(2048)) // returns false +``` + +Along the way, the data was buffered and deferred at each stage, and +multiple event deferrals happened, for an unblocked pipeline where it was +perfectly safe to write all the way through! + +Furthermore, setting a `highWaterMark` of `1024` might lead someone reading +the code to think an advisory maximum of 1KiB is being set for the +pipeline. However, the actual advisory buffering level is the _sum_ of +`highWaterMark` values, since each one has its own bucket. + +Consider the Minipass case: + +```js +const m1 = new Minipass() +const m2 = new Minipass() +const m3 = new Minipass() +const m4 = new Minipass() + +m1.pipe(m2).pipe(m3).pipe(m4) +m4.on('data', () => console.log('made it through')) + +// m1 is flowing, so it writes the data to m2 immediately +// m2 is flowing, so it writes the data to m3 immediately +// m3 is flowing, so it writes the data to m4 immediately +// m4 is flowing, so it fires the 'data' event immediately, returns true +// m4's write returned true, so m3 is still flowing, returns true +// m3's write returned true, so m2 is still flowing, returns true +// m2's write returned true, so m1 is still flowing, returns true +// No event deferrals or buffering along the way! + +m1.write(Buffer.alloc(2048)) // returns true +``` + +It is extremely unlikely that you _don't_ want to buffer any data written, +or _ever_ buffer data that can be flushed all the way through. Neither +node-core streams nor Minipass ever fail to buffer written data, but +node-core streams do a lot of unnecessary buffering and pausing. + +As always, the faster implementation is the one that does less stuff and +waits less time to do it. + +### Immediately emit `end` for empty streams (when not paused) + +If a stream is not paused, and `end()` is called before writing any data +into it, then it will emit `end` immediately. + +If you have logic that occurs on the `end` event which you don't want to +potentially happen immediately (for example, closing file descriptors, +moving on to the next entry in an archive parse stream, etc.) then be sure +to call `stream.pause()` on creation, and then `stream.resume()` once you +are ready to respond to the `end` event. + +### Emit `end` When Asked + +One hazard of immediately emitting `'end'` is that you may not yet have had +a chance to add a listener. In order to avoid this hazard, Minipass +streams safely re-emit the `'end'` event if a new listener is added after +`'end'` has been emitted. + +Ie, if you do `stream.on('end', someFunction)`, and the stream has already +emitted `end`, then it will call the handler right away. (You can think of +this somewhat like attaching a new `.then(fn)` to a previously-resolved +Promise.) + +To prevent calling handlers multiple times who would not expect multiple +ends to occur, all listeners are removed from the `'end'` event whenever it +is emitted. + +### Impact of "immediate flow" on Tee-streams + +A "tee stream" is a stream piping to multiple destinations: + +```js +const tee = new Minipass() +t.pipe(dest1) +t.pipe(dest2) +t.write('foo') // goes to both destinations +``` + +Since Minipass streams _immediately_ process any pending data through the +pipeline when a new pipe destination is added, this can have surprising +effects, especially when a stream comes in from some other function and may +or may not have data in its buffer. + +```js +// WARNING! WILL LOSE DATA! +const src = new Minipass() +src.write('foo') +src.pipe(dest1) // 'foo' chunk flows to dest1 immediately, and is gone +src.pipe(dest2) // gets nothing! +``` + +The solution is to create a dedicated tee-stream junction that pipes to +both locations, and then pipe to _that_ instead. + +```js +// Safe example: tee to both places +const src = new Minipass() +src.write('foo') +const tee = new Minipass() +tee.pipe(dest1) +tee.pipe(dest2) +stream.pipe(tee) // tee gets 'foo', pipes to both locations +``` + +The same caveat applies to `on('data')` event listeners. The first one +added will _immediately_ receive all of the data, leaving nothing for the +second: + +```js +// WARNING! WILL LOSE DATA! +const src = new Minipass() +src.write('foo') +src.on('data', handler1) // receives 'foo' right away +src.on('data', handler2) // nothing to see here! +``` + +Using a dedicated tee-stream can be used in this case as well: + +```js +// Safe example: tee to both data handlers +const src = new Minipass() +src.write('foo') +const tee = new Minipass() +tee.on('data', handler1) +tee.on('data', handler2) +src.pipe(tee) +``` ## USAGE +It's a stream! Use it like a stream and it'll most likely do what you want. + ```js -const MiniPass = require('minipass') -const mp = new MiniPass(options) // optional: { encoding } +const Minipass = require('minipass') +const mp = new Minipass(options) // optional: { encoding, objectMode } mp.write('foo') mp.pipe(someOtherStream) mp.end('bar') ``` +### OPTIONS + +* `encoding` How would you like the data coming _out_ of the stream to be + encoded? Accepts any values that can be passed to `Buffer.toString()`. +* `objectMode` Emit data exactly as it comes in. This will be flipped on + by default if you write() something other than a string or Buffer at any + point. Setting `objectMode: true` will prevent setting any encoding + value. + +### API + +Implements the user-facing portions of Node.js's `Readable` and `Writable` +streams. + +### Methods + +* `write(chunk, [encoding], [callback])` - Put data in. (Note that, in the + base Minipass class, the same data will come out.) Returns `false` if + the stream will buffer the next write, or true if it's still in + "flowing" mode. +* `end([chunk, [encoding]], [callback])` - Signal that you have no more + data to write. This will queue an `end` event to be fired when all the + data has been consumed. +* `setEncoding(encoding)` - Set the encoding for data coming of the + stream. This can only be done once. +* `pause()` - No more data for a while, please. This also prevents `end` + from being emitted for empty streams until the stream is resumed. +* `resume()` - Resume the stream. If there's data in the buffer, it is + all discarded. Any buffered events are immediately emitted. +* `pipe(dest)` - Send all output to the stream provided. There is no way + to unpipe. When data is emitted, it is immediately written to any and + all pipe destinations. +* `on(ev, fn)`, `emit(ev, fn)` - Minipass streams are EventEmitters. + Some events are given special treatment, however. (See below under + "events".) +* `promise()` - Returns a Promise that resolves when the stream emits + `end`, or rejects if the stream emits `error`. +* `collect()` - Return a Promise that resolves on `end` with an array + containing each chunk of data that was emitted, or rejects if the + stream emits `error`. Note that this consumes the stream data. +* `concat()` - Same as `collect()`, but concatenates the data into a + single Buffer object. Will reject the returned promise if the stream is + in objectMode, or if it goes into objectMode by the end of the data. +* `read(n)` - Consume `n` bytes of data out of the buffer. If `n` is not + provided, then consume all of it. If `n` bytes are not available, then + it returns null. **Note** consuming streams in this way is less + efficient, and can lead to unnecessary Buffer copying. +* `destroy([er])` - Destroy the stream. If an error is provided, then an + `'error'` event is emitted. If the stream has a `close()` method, and + has not emitted a `'close'` event yet, then `stream.close()` will be + called. Any Promises returned by `.promise()`, `.collect()` or + `.concat()` will be rejected. After being destroyed, writing to the + stream will emit an error. No more data will be emitted if the stream is + destroyed, even if it was previously buffered. + +### Properties + +* `bufferLength` Read-only. Total number of bytes buffered, or in the case + of objectMode, the total number of objects. +* `encoding` The encoding that has been set. (Setting this is equivalent + to calling `setEncoding(enc)` and has the same prohibition against + setting multiple times.) +* `flowing` Read-only. Boolean indicating whether a chunk written to the + stream will be immediately emitted. +* `emittedEnd` Read-only. Boolean indicating whether the end-ish events + (ie, `end`, `prefinish`, `finish`) have been emitted. Note that + listening on any end-ish event will immediateyl re-emit it if it has + already been emitted. +* `writable` Whether the stream is writable. Default `true`. Set to + `false` when `end()` +* `readable` Whether the stream is readable. Default `true`. +* `buffer` A [yallist](http://npm.im/yallist) linked list of chunks written + to the stream that have not yet been emitted. (It's probably a bad idea + to mess with this.) +* `pipes` A [yallist](http://npm.im/yallist) linked list of streams that + this stream is piping into. (It's probably a bad idea to mess with + this.) +* `destroyed` A getter that indicates whether the stream was destroyed. +* `paused` True if the stream has been explicitly paused, otherwise false. +* `objectMode` Indicates whether the stream is in `objectMode`. Once set + to `true`, it cannot be set to `false`. + +### Events + +* `data` Emitted when there's data to read. Argument is the data to read. + This is never emitted while not flowing. If a listener is attached, that + will resume the stream. +* `end` Emitted when there's no more data to read. This will be emitted + immediately for empty streams when `end()` is called. If a listener is + attached, and `end` was already emitted, then it will be emitted again. + All listeners are removed when `end` is emitted. +* `prefinish` An end-ish event that follows the same logic as `end` and is + emitted in the same conditions where `end` is emitted. Emitted after + `'end'`. +* `finish` An end-ish event that follows the same logic as `end` and is + emitted in the same conditions where `end` is emitted. Emitted after + `'prefinish'`. +* `close` An indication that an underlying resource has been released. + Minipass does not emit this event, but will defer it until after `end` + has been emitted, since it throws off some stream libraries otherwise. +* `drain` Emitted when the internal buffer empties, and it is again + suitable to `write()` into the stream. +* `readable` Emitted when data is buffered and ready to be read by a + consumer. +* `resume` Emitted when stream changes state from buffering to flowing + mode. (Ie, when `resume` is called, `pipe` is called, or a `data` event + listener is added.) + +### Static Methods + +* `Minipass.isStream(stream)` Returns `true` if the argument is a stream, + and false otherwise. To be considered a stream, the object must be + either an instance of Minipass, or an EventEmitter that has either a + `pipe()` method, or both `write()` and `end()` methods. (Pretty much any + stream in node-land will return `true` for this.) + +## EXAMPLES + +Here are some examples of things you can do with Minipass streams. + +### simple "are you done yet" promise + +```js +mp.promise().then(() => { + // stream is finished +}, er => { + // stream emitted an error +}) +``` + ### collecting ```js @@ -57,6 +406,19 @@ mp.collect().then(all => { }) ``` +### collecting into a single blob + +This is a bit slower because it concatenates the data into one chunk for +you, but if you're going to do it yourself anyway, it's convenient this +way: + +```js +mp.concat().then(onebigchunk => { + // onebigchunk is a string if the stream + // had an encoding set, or a buffer otherwise. +}) +``` + ### iteration You can iterate over streams synchronously or asynchronously in @@ -122,3 +484,123 @@ async function consume () { consume().then(res => console.log(res)) // logs `foo\n` 5 times, and then `ok` ``` + +### subclass that `console.log()`s everything written into it + +```js +class Logger extends Minipass { + write (chunk, encoding, callback) { + console.log('WRITE', chunk, encoding) + return super.write(chunk, encoding, callback) + } + end (chunk, encoding, callback) { + console.log('END', chunk, encoding) + return super.end(chunk, encoding, callback) + } +} + +someSource.pipe(new Logger()).pipe(someDest) +``` + +### same thing, but using an inline anonymous class + +```js +// js classes are fun +someSource + .pipe(new (class extends Minipass { + emit (ev, ...data) { + // let's also log events, because debugging some weird thing + console.log('EMIT', ev) + return super.emit(ev, ...data) + } + write (chunk, encoding, callback) { + console.log('WRITE', chunk, encoding) + return super.write(chunk, encoding, callback) + } + end (chunk, encoding, callback) { + console.log('END', chunk, encoding) + return super.end(chunk, encoding, callback) + } + })) + .pipe(someDest) +``` + +### subclass that defers 'end' for some reason + +```js +class SlowEnd extends Minipass { + emit (ev, ...args) { + if (ev === 'end') { + console.log('going to end, hold on a sec') + setTimeout(() => { + console.log('ok, ready to end now') + super.emit('end', ...args) + }, 100) + } else { + return super.emit(ev, ...args) + } + } +} +``` + +### transform that creates newline-delimited JSON + +```js +class NDJSONEncode extends Minipass { + write (obj, cb) { + try { + // JSON.stringify can throw, emit an error on that + return super.write(JSON.stringify(obj) + '\n', 'utf8', cb) + } catch (er) { + this.emit('error', er) + } + } + end (obj, cb) { + if (typeof obj === 'function') { + cb = obj + obj = undefined + } + if (obj !== undefined) { + this.write(obj) + } + return super.end(cb) + } +} +``` + +### transform that parses newline-delimited JSON + +```js +class NDJSONDecode extends Minipass { + constructor (options) { + // always be in object mode, as far as Minipass is concerned + super({ objectMode: true }) + this._jsonBuffer = '' + } + write (chunk, encoding, cb) { + if (typeof chunk === 'string' && + typeof encoding === 'string' && + encoding !== 'utf8') { + chunk = Buffer.from(chunk, encoding).toString() + } else if (Buffer.isBuffer(chunk)) + chunk = chunk.toString() + } + if (typeof encoding === 'function') { + cb = encoding + } + const jsonData = (this._jsonBuffer + chunk).split('\n') + this._jsonBuffer = jsonData.pop() + for (let i = 0; i < jsonData.length; i++) { + let parsed + try { + super.write(parsed) + } catch (er) { + this.emit('error', er) + continue + } + } + if (cb) + cb() + } +} +``` diff --git a/node_modules/tar/node_modules/minipass/index.js b/node_modules/tar/node_modules/minipass/index.js index de472c36e7684..cab9009f2befb 100644 --- a/node_modules/tar/node_modules/minipass/index.js +++ b/node_modules/tar/node_modules/minipass/index.js @@ -1,39 +1,54 @@ 'use strict' const EE = require('events') const Yallist = require('yallist') +const SD = require('string_decoder').StringDecoder + const EOF = Symbol('EOF') const MAYBE_EMIT_END = Symbol('maybeEmitEnd') const EMITTED_END = Symbol('emittedEnd') +const EMITTING_END = Symbol('emittingEnd') const CLOSED = Symbol('closed') const READ = Symbol('read') const FLUSH = Symbol('flush') -const doIter = process.env._MP_NO_ITERATOR_SYMBOLS_ !== '1' -const ASYNCITERATOR = doIter && Symbol.asyncIterator || Symbol('asyncIterator not implemented') -const ITERATOR = doIter && Symbol.iterator || Symbol('iterator not implemented') const FLUSHCHUNK = Symbol('flushChunk') -const SD = require('string_decoder').StringDecoder const ENCODING = Symbol('encoding') const DECODER = Symbol('decoder') const FLOWING = Symbol('flowing') +const PAUSED = Symbol('paused') const RESUME = Symbol('resume') const BUFFERLENGTH = Symbol('bufferLength') const BUFFERPUSH = Symbol('bufferPush') const BUFFERSHIFT = Symbol('bufferShift') const OBJECTMODE = Symbol('objectMode') +const DESTROYED = Symbol('destroyed') + +// TODO remove when Node v8 support drops +const doIter = global._MP_NO_ITERATOR_SYMBOLS_ !== '1' +const ASYNCITERATOR = doIter && Symbol.asyncIterator + || Symbol('asyncIterator not implemented') +const ITERATOR = doIter && Symbol.iterator + || Symbol('iterator not implemented') // Buffer in node 4.x < 4.5.0 doesn't have working Buffer.from // or Buffer.alloc, and Buffer in node 10 deprecated the ctor. // .M, this is fine .\^/M.. -let B = Buffer -/* istanbul ignore next */ -if (!B.alloc) { - B = require('safe-buffer').Buffer -} - -module.exports = class MiniPass extends EE { +const B = Buffer.alloc ? Buffer + : /* istanbul ignore next */ require('safe-buffer').Buffer + +// events that mean 'the stream is over' +// these are treated specially, and re-emitted +// if they are listened for after emitting. +const isEndish = ev => + ev === 'end' || + ev === 'finish' || + ev === 'prefinish' + +module.exports = class Minipass extends EE { constructor (options) { super() this[FLOWING] = false + // whether we're explicitly paused + this[PAUSED] = false this.pipes = new Yallist() this.buffer = new Yallist() this[OBJECTMODE] = options && options.objectMode || false @@ -46,10 +61,12 @@ module.exports = class MiniPass extends EE { this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null this[EOF] = false this[EMITTED_END] = false + this[EMITTING_END] = false this[CLOSED] = false this.writable = true this.readable = true this[BUFFERLENGTH] = 0 + this[DESTROYED] = false } get bufferLength () { return this[BUFFERLENGTH] } @@ -76,16 +93,41 @@ module.exports = class MiniPass extends EE { this.encoding = enc } + get objectMode () { return this[OBJECTMODE] } + set objectMode (ॐ ) { this[OBJECTMODE] = this[OBJECTMODE] || !!ॐ } + write (chunk, encoding, cb) { if (this[EOF]) throw new Error('write after end') + if (this[DESTROYED]) { + this.emit('error', Object.assign( + new Error('Cannot call write after a stream was destroyed'), + { code: 'ERR_STREAM_DESTROYED' } + )) + return true + } + if (typeof encoding === 'function') cb = encoding, encoding = 'utf8' if (!encoding) encoding = 'utf8' + if (typeof chunk !== 'string' && !B.isBuffer(chunk) && !this[OBJECTMODE]) + this.objectMode = true + + // this ensures at this point that the chunk is a buffer or string + // don't buffer it up or send it to the decoder + if (!this.objectMode && !chunk.length) { + const ret = this.flowing + if (this[BUFFERLENGTH] !== 0) + this.emit('readable') + if (cb) + cb() + return ret + } + // fast-path writing strings of same encoding to a stream with // an empty buffer, skipping the buffer/decoder dance if (typeof chunk === 'string' && !this[OBJECTMODE] && @@ -102,13 +144,17 @@ module.exports = class MiniPass extends EE { ? (this.emit('data', chunk), this.flowing) : (this[BUFFERPUSH](chunk), false) } finally { - this.emit('readable') + if (this[BUFFERLENGTH] !== 0) + this.emit('readable') if (cb) cb() } } read (n) { + if (this[DESTROYED]) + return null + try { if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH]) return null @@ -161,12 +207,22 @@ module.exports = class MiniPass extends EE { this.once('end', cb) this[EOF] = true this.writable = false - if (this.flowing) + + // if we haven't written anything, then go ahead and emit, + // even if we're not reading. + // we'll re-emit if a new 'end' listener is added anyway. + // This makes MP more suitable to write-only use cases. + if (this.flowing || !this[PAUSED]) this[MAYBE_EMIT_END]() + return this } // don't let the internal resume be overwritten [RESUME] () { + if (this[DESTROYED]) + return + + this[PAUSED] = false this[FLOWING] = true this.emit('resume') if (this.buffer.length) @@ -183,12 +239,21 @@ module.exports = class MiniPass extends EE { pause () { this[FLOWING] = false + this[PAUSED] = true + } + + get destroyed () { + return this[DESTROYED] } get flowing () { return this[FLOWING] } + get paused () { + return this[PAUSED] + } + [BUFFERPUSH] (chunk) { if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1 @@ -219,13 +284,24 @@ module.exports = class MiniPass extends EE { } pipe (dest, opts) { + if (this[DESTROYED]) + return + + const ended = this[EMITTED_END] + opts = opts || {} if (dest === process.stdout || dest === process.stderr) - (opts = opts || {}).end = false + opts.end = false + else + opts.end = opts.end !== false + const p = { dest: dest, opts: opts, ondrain: _ => this[RESUME]() } this.pipes.push(p) dest.on('drain', p.ondrain) this[RESUME]() + // piping an ended stream ends immediately + if (ended && p.opts.end) + p.dest.end() return dest } @@ -239,9 +315,9 @@ module.exports = class MiniPass extends EE { } finally { if (ev === 'data' && !this.pipes.length && !this.flowing) this[RESUME]() - else if (ev === 'end' && this[EMITTED_END]) { - super.emit('end') - this.removeAllListeners('end') + else if (isEndish(ev) && this[EMITTED_END]) { + super.emit(ev) + this.removeAllListeners(ev) } } } @@ -251,23 +327,34 @@ module.exports = class MiniPass extends EE { } [MAYBE_EMIT_END] () { - if (!this[EMITTED_END] && this.buffer.length === 0 && this[EOF]) { + if (!this[EMITTING_END] && + !this[EMITTED_END] && + !this[DESTROYED] && + this.buffer.length === 0 && + this[EOF]) { + this[EMITTING_END] = true this.emit('end') this.emit('prefinish') this.emit('finish') if (this[CLOSED]) this.emit('close') + this[EMITTING_END] = false } } emit (ev, data) { - if (ev === 'data') { + // error and close are only events allowed after calling destroy() + if (ev !== 'error' && ev !== 'close' && ev !== DESTROYED && this[DESTROYED]) + return + else if (ev === 'data') { if (!data) return if (this.pipes.length) - this.pipes.forEach(p => p.dest.write(data) || this.pause()) + this.pipes.forEach(p => + p.dest.write(data) === false && this.pause()) } else if (ev === 'end') { + // only actual end gets this treatment if (this[EMITTED_END] === true) return @@ -284,16 +371,17 @@ module.exports = class MiniPass extends EE { this.pipes.forEach(p => { p.dest.removeListener('drain', p.ondrain) - if (!p.opts || p.opts.end !== false) + if (p.opts.end) p.dest.end() }) } else if (ev === 'close') { this[CLOSED] = true // don't emit close before 'end' and 'finish' - if (!this[EMITTED_END]) + if (!this[EMITTED_END] && !this[DESTROYED]) return } + // TODO: replace with a spread operator when Node v4 support drops const args = new Array(arguments.length) args[0] = ev args[1] = data @@ -306,20 +394,40 @@ module.exports = class MiniPass extends EE { try { return super.emit.apply(this, args) } finally { - if (ev !== 'end') + if (!isEndish(ev)) this[MAYBE_EMIT_END]() else - this.removeAllListeners('end') + this.removeAllListeners(ev) } } // const all = await stream.collect() collect () { + const buf = [] + buf.dataLength = 0 + this.on('data', c => { + buf.push(c) + buf.dataLength += c.length + }) + return this.promise().then(() => buf) + } + + // const data = await stream.concat() + concat () { + return this[OBJECTMODE] + ? Promise.reject(new Error('cannot concat in objectMode')) + : this.collect().then(buf => + this[OBJECTMODE] + ? Promise.reject(new Error('cannot concat in objectMode')) + : this[ENCODING] ? buf.join('') : B.concat(buf, buf.dataLength)) + } + + // stream.promise().then(() => done, er => emitted error) + promise () { return new Promise((resolve, reject) => { - const buf = [] - this.on('data', c => buf.push(c)) - this.on('end', () => resolve(buf)) - this.on('error', reject) + this.on(DESTROYED, () => reject(new Error('stream destroyed'))) + this.on('end', () => resolve()) + this.on('error', er => reject(er)) }) } @@ -351,9 +459,11 @@ module.exports = class MiniPass extends EE { this.removeListener('data', ondata) resolve({ done: true }) } + const ondestroy = () => onerr(new Error('stream destroyed')) return new Promise((res, rej) => { reject = rej resolve = res + this.once(DESTROYED, ondestroy) this.once('error', onerr) this.once('end', onend) this.once('data', ondata) @@ -372,4 +482,37 @@ module.exports = class MiniPass extends EE { } return { next } } + + destroy (er) { + if (this[DESTROYED]) { + if (er) + this.emit('error', er) + else + this.emit(DESTROYED) + return this + } + + this[DESTROYED] = true + + // throw away all buffered data, it's never coming out + this.buffer = new Yallist() + this[BUFFERLENGTH] = 0 + + if (typeof this.close === 'function' && !this[CLOSED]) + this.close() + + if (er) + this.emit('error', er) + else // if no error to emit, still reject pending promises + this.emit(DESTROYED) + + return this + } + + static isStream (s) { + return !!s && (s instanceof Minipass || s instanceof EE && ( + typeof s.pipe === 'function' || // readable + (typeof s.write === 'function' && typeof s.end === 'function') // writable + )) + } } diff --git a/node_modules/tar/node_modules/minipass/package.json b/node_modules/tar/node_modules/minipass/package.json index d38e18f6ef00f..5c782f120d18f 100644 --- a/node_modules/tar/node_modules/minipass/package.json +++ b/node_modules/tar/node_modules/minipass/package.json @@ -1,27 +1,27 @@ { - "_from": "minipass@^2.3.4", - "_id": "minipass@2.3.5", + "_from": "minipass@^2.8.6", + "_id": "minipass@2.8.6", "_inBundle": false, - "_integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "_integrity": "sha512-lFG7d6g3+/UaFDCOtqPiKAC9zngWWsQZl1g5q6gaONqrjq61SX2xFqXMleQiFVyDpYwa018E9hmlAFY22PCb+A==", "_location": "/tar/minipass", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "minipass@^2.3.4", + "raw": "minipass@^2.8.6", "name": "minipass", "escapedName": "minipass", - "rawSpec": "^2.3.4", + "rawSpec": "^2.8.6", "saveSpec": null, - "fetchSpec": "^2.3.4" + "fetchSpec": "^2.8.6" }, "_requiredBy": [ "/tar" ], - "_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "_shasum": "cacebe492022497f656b0f0f51e2682a9ed2d848", - "_spec": "minipass@^2.3.4", - "_where": "/Users/zkat/Documents/code/work/npm/node_modules/tar", + "_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.8.6.tgz", + "_shasum": "620d889ace26356391d010ecb9458749df9b6db5", + "_spec": "minipass@^2.8.6", + "_where": "/Users/mperrotte/npminc/cli/node_modules/tar", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -39,7 +39,7 @@ "description": "minimal implementation of a PassThrough stream", "devDependencies": { "end-of-stream": "^1.4.0", - "tap": "^12.0.1", + "tap": "^14.6.4", "through2": "^2.0.3" }, "files": [ @@ -58,10 +58,13 @@ "url": "git+https://github.com/isaacs/minipass.git" }, "scripts": { - "postpublish": "git push origin --all; git push origin --tags", + "postpublish": "git push origin --follow-tags", "postversion": "npm publish", "preversion": "npm test", - "test": "tap test/*.js --100" + "test": "tap" }, - "version": "2.3.5" + "tap": { + "check-coverage": true + }, + "version": "2.8.6" } diff --git a/node_modules/tar/node_modules/yallist/README.md b/node_modules/tar/node_modules/yallist/README.md deleted file mode 100644 index f586101869668..0000000000000 --- a/node_modules/tar/node_modules/yallist/README.md +++ /dev/null @@ -1,204 +0,0 @@ -# yallist - -Yet Another Linked List - -There are many doubly-linked list implementations like it, but this -one is mine. - -For when an array would be too big, and a Map can't be iterated in -reverse order. - - -[![Build Status](https://travis-ci.org/isaacs/yallist.svg?branch=master)](https://travis-ci.org/isaacs/yallist) [![Coverage Status](https://coveralls.io/repos/isaacs/yallist/badge.svg?service=github)](https://coveralls.io/github/isaacs/yallist) - -## basic usage - -```javascript -var yallist = require('yallist') -var myList = yallist.create([1, 2, 3]) -myList.push('foo') -myList.unshift('bar') -// of course pop() and shift() are there, too -console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo'] -myList.forEach(function (k) { - // walk the list head to tail -}) -myList.forEachReverse(function (k, index, list) { - // walk the list tail to head -}) -var myDoubledList = myList.map(function (k) { - return k + k -}) -// now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo'] -// mapReverse is also a thing -var myDoubledListReverse = myList.mapReverse(function (k) { - return k + k -}) // ['foofoo', 6, 4, 2, 'barbar'] - -var reduced = myList.reduce(function (set, entry) { - set += entry - return set -}, 'start') -console.log(reduced) // 'startfoo123bar' -``` - -## api - -The whole API is considered "public". - -Functions with the same name as an Array method work more or less the -same way. - -There's reverse versions of most things because that's the point. - -### Yallist - -Default export, the class that holds and manages a list. - -Call it with either a forEach-able (like an array) or a set of -arguments, to initialize the list. - -The Array-ish methods all act like you'd expect. No magic length, -though, so if you change that it won't automatically prune or add -empty spots. - -### Yallist.create(..) - -Alias for Yallist function. Some people like factories. - -#### yallist.head - -The first node in the list - -#### yallist.tail - -The last node in the list - -#### yallist.length - -The number of nodes in the list. (Change this at your peril. It is -not magic like Array length.) - -#### yallist.toArray() - -Convert the list to an array. - -#### yallist.forEach(fn, [thisp]) - -Call a function on each item in the list. - -#### yallist.forEachReverse(fn, [thisp]) - -Call a function on each item in the list, in reverse order. - -#### yallist.get(n) - -Get the data at position `n` in the list. If you use this a lot, -probably better off just using an Array. - -#### yallist.getReverse(n) - -Get the data at position `n`, counting from the tail. - -#### yallist.map(fn, thisp) - -Create a new Yallist with the result of calling the function on each -item. - -#### yallist.mapReverse(fn, thisp) - -Same as `map`, but in reverse. - -#### yallist.pop() - -Get the data from the list tail, and remove the tail from the list. - -#### yallist.push(item, ...) - -Insert one or more items to the tail of the list. - -#### yallist.reduce(fn, initialValue) - -Like Array.reduce. - -#### yallist.reduceReverse - -Like Array.reduce, but in reverse. - -#### yallist.reverse - -Reverse the list in place. - -#### yallist.shift() - -Get the data from the list head, and remove the head from the list. - -#### yallist.slice([from], [to]) - -Just like Array.slice, but returns a new Yallist. - -#### yallist.sliceReverse([from], [to]) - -Just like yallist.slice, but the result is returned in reverse. - -#### yallist.toArray() - -Create an array representation of the list. - -#### yallist.toArrayReverse() - -Create a reversed array representation of the list. - -#### yallist.unshift(item, ...) - -Insert one or more items to the head of the list. - -#### yallist.unshiftNode(node) - -Move a Node object to the front of the list. (That is, pull it out of -wherever it lives, and make it the new head.) - -If the node belongs to a different list, then that list will remove it -first. - -#### yallist.pushNode(node) - -Move a Node object to the end of the list. (That is, pull it out of -wherever it lives, and make it the new tail.) - -If the node belongs to a list already, then that list will remove it -first. - -#### yallist.removeNode(node) - -Remove a node from the list, preserving referential integrity of head -and tail and other nodes. - -Will throw an error if you try to have a list remove a node that -doesn't belong to it. - -### Yallist.Node - -The class that holds the data and is actually the list. - -Call with `var n = new Node(value, previousNode, nextNode)` - -Note that if you do direct operations on Nodes themselves, it's very -easy to get into weird states where the list is broken. Be careful :) - -#### node.next - -The next node in the list. - -#### node.prev - -The previous node in the list. - -#### node.value - -The data the node contains. - -#### node.list - -The list to which this node belongs. (Null if it does not belong to -any list.) diff --git a/node_modules/tar/node_modules/yallist/iterator.js b/node_modules/tar/node_modules/yallist/iterator.js deleted file mode 100644 index d41c97a19f984..0000000000000 --- a/node_modules/tar/node_modules/yallist/iterator.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict' -module.exports = function (Yallist) { - Yallist.prototype[Symbol.iterator] = function* () { - for (let walker = this.head; walker; walker = walker.next) { - yield walker.value - } - } -} diff --git a/node_modules/tar/node_modules/yallist/package.json b/node_modules/tar/node_modules/yallist/package.json deleted file mode 100644 index f24c8d0c7a140..0000000000000 --- a/node_modules/tar/node_modules/yallist/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "_from": "yallist@^3.0.2", - "_id": "yallist@3.0.3", - "_inBundle": false, - "_integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "_location": "/tar/yallist", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "yallist@^3.0.2", - "name": "yallist", - "escapedName": "yallist", - "rawSpec": "^3.0.2", - "saveSpec": null, - "fetchSpec": "^3.0.2" - }, - "_requiredBy": [ - "/tar", - "/tar/minipass" - ], - "_resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "_shasum": "b4b049e314be545e3ce802236d6cd22cd91c3de9", - "_spec": "yallist@^3.0.2", - "_where": "/Users/zkat/Documents/code/work/npm/node_modules/tar", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "bugs": { - "url": "https://github.com/isaacs/yallist/issues" - }, - "bundleDependencies": false, - "dependencies": {}, - "deprecated": false, - "description": "Yet Another Linked List", - "devDependencies": { - "tap": "^12.1.0" - }, - "directories": { - "test": "test" - }, - "files": [ - "yallist.js", - "iterator.js" - ], - "homepage": "https://github.com/isaacs/yallist#readme", - "license": "ISC", - "main": "yallist.js", - "name": "yallist", - "repository": { - "type": "git", - "url": "git+https://github.com/isaacs/yallist.git" - }, - "scripts": { - "postpublish": "git push origin --all; git push origin --tags", - "postversion": "npm publish", - "preversion": "npm test", - "test": "tap test/*.js --100" - }, - "version": "3.0.3" -} diff --git a/node_modules/tar/node_modules/yallist/yallist.js b/node_modules/tar/node_modules/yallist/yallist.js deleted file mode 100644 index b0ab36cf31b7a..0000000000000 --- a/node_modules/tar/node_modules/yallist/yallist.js +++ /dev/null @@ -1,376 +0,0 @@ -'use strict' -module.exports = Yallist - -Yallist.Node = Node -Yallist.create = Yallist - -function Yallist (list) { - var self = this - if (!(self instanceof Yallist)) { - self = new Yallist() - } - - self.tail = null - self.head = null - self.length = 0 - - if (list && typeof list.forEach === 'function') { - list.forEach(function (item) { - self.push(item) - }) - } else if (arguments.length > 0) { - for (var i = 0, l = arguments.length; i < l; i++) { - self.push(arguments[i]) - } - } - - return self -} - -Yallist.prototype.removeNode = function (node) { - if (node.list !== this) { - throw new Error('removing node which does not belong to this list') - } - - var next = node.next - var prev = node.prev - - if (next) { - next.prev = prev - } - - if (prev) { - prev.next = next - } - - if (node === this.head) { - this.head = next - } - if (node === this.tail) { - this.tail = prev - } - - node.list.length-- - node.next = null - node.prev = null - node.list = null -} - -Yallist.prototype.unshiftNode = function (node) { - if (node === this.head) { - return - } - - if (node.list) { - node.list.removeNode(node) - } - - var head = this.head - node.list = this - node.next = head - if (head) { - head.prev = node - } - - this.head = node - if (!this.tail) { - this.tail = node - } - this.length++ -} - -Yallist.prototype.pushNode = function (node) { - if (node === this.tail) { - return - } - - if (node.list) { - node.list.removeNode(node) - } - - var tail = this.tail - node.list = this - node.prev = tail - if (tail) { - tail.next = node - } - - this.tail = node - if (!this.head) { - this.head = node - } - this.length++ -} - -Yallist.prototype.push = function () { - for (var i = 0, l = arguments.length; i < l; i++) { - push(this, arguments[i]) - } - return this.length -} - -Yallist.prototype.unshift = function () { - for (var i = 0, l = arguments.length; i < l; i++) { - unshift(this, arguments[i]) - } - return this.length -} - -Yallist.prototype.pop = function () { - if (!this.tail) { - return undefined - } - - var res = this.tail.value - this.tail = this.tail.prev - if (this.tail) { - this.tail.next = null - } else { - this.head = null - } - this.length-- - return res -} - -Yallist.prototype.shift = function () { - if (!this.head) { - return undefined - } - - var res = this.head.value - this.head = this.head.next - if (this.head) { - this.head.prev = null - } else { - this.tail = null - } - this.length-- - return res -} - -Yallist.prototype.forEach = function (fn, thisp) { - thisp = thisp || this - for (var walker = this.head, i = 0; walker !== null; i++) { - fn.call(thisp, walker.value, i, this) - walker = walker.next - } -} - -Yallist.prototype.forEachReverse = function (fn, thisp) { - thisp = thisp || this - for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { - fn.call(thisp, walker.value, i, this) - walker = walker.prev - } -} - -Yallist.prototype.get = function (n) { - for (var i = 0, walker = this.head; walker !== null && i < n; i++) { - // abort out of the list early if we hit a cycle - walker = walker.next - } - if (i === n && walker !== null) { - return walker.value - } -} - -Yallist.prototype.getReverse = function (n) { - for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { - // abort out of the list early if we hit a cycle - walker = walker.prev - } - if (i === n && walker !== null) { - return walker.value - } -} - -Yallist.prototype.map = function (fn, thisp) { - thisp = thisp || this - var res = new Yallist() - for (var walker = this.head; walker !== null;) { - res.push(fn.call(thisp, walker.value, this)) - walker = walker.next - } - return res -} - -Yallist.prototype.mapReverse = function (fn, thisp) { - thisp = thisp || this - var res = new Yallist() - for (var walker = this.tail; walker !== null;) { - res.push(fn.call(thisp, walker.value, this)) - walker = walker.prev - } - return res -} - -Yallist.prototype.reduce = function (fn, initial) { - var acc - var walker = this.head - if (arguments.length > 1) { - acc = initial - } else if (this.head) { - walker = this.head.next - acc = this.head.value - } else { - throw new TypeError('Reduce of empty list with no initial value') - } - - for (var i = 0; walker !== null; i++) { - acc = fn(acc, walker.value, i) - walker = walker.next - } - - return acc -} - -Yallist.prototype.reduceReverse = function (fn, initial) { - var acc - var walker = this.tail - if (arguments.length > 1) { - acc = initial - } else if (this.tail) { - walker = this.tail.prev - acc = this.tail.value - } else { - throw new TypeError('Reduce of empty list with no initial value') - } - - for (var i = this.length - 1; walker !== null; i--) { - acc = fn(acc, walker.value, i) - walker = walker.prev - } - - return acc -} - -Yallist.prototype.toArray = function () { - var arr = new Array(this.length) - for (var i = 0, walker = this.head; walker !== null; i++) { - arr[i] = walker.value - walker = walker.next - } - return arr -} - -Yallist.prototype.toArrayReverse = function () { - var arr = new Array(this.length) - for (var i = 0, walker = this.tail; walker !== null; i++) { - arr[i] = walker.value - walker = walker.prev - } - return arr -} - -Yallist.prototype.slice = function (from, to) { - to = to || this.length - if (to < 0) { - to += this.length - } - from = from || 0 - if (from < 0) { - from += this.length - } - var ret = new Yallist() - if (to < from || to < 0) { - return ret - } - if (from < 0) { - from = 0 - } - if (to > this.length) { - to = this.length - } - for (var i = 0, walker = this.head; walker !== null && i < from; i++) { - walker = walker.next - } - for (; walker !== null && i < to; i++, walker = walker.next) { - ret.push(walker.value) - } - return ret -} - -Yallist.prototype.sliceReverse = function (from, to) { - to = to || this.length - if (to < 0) { - to += this.length - } - from = from || 0 - if (from < 0) { - from += this.length - } - var ret = new Yallist() - if (to < from || to < 0) { - return ret - } - if (from < 0) { - from = 0 - } - if (to > this.length) { - to = this.length - } - for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { - walker = walker.prev - } - for (; walker !== null && i > from; i--, walker = walker.prev) { - ret.push(walker.value) - } - return ret -} - -Yallist.prototype.reverse = function () { - var head = this.head - var tail = this.tail - for (var walker = head; walker !== null; walker = walker.prev) { - var p = walker.prev - walker.prev = walker.next - walker.next = p - } - this.head = tail - this.tail = head - return this -} - -function push (self, item) { - self.tail = new Node(item, self.tail, null, self) - if (!self.head) { - self.head = self.tail - } - self.length++ -} - -function unshift (self, item) { - self.head = new Node(item, null, self.head, self) - if (!self.tail) { - self.tail = self.head - } - self.length++ -} - -function Node (value, prev, next, list) { - if (!(this instanceof Node)) { - return new Node(value, prev, next, list) - } - - this.list = list - this.value = value - - if (prev) { - prev.next = this - this.prev = prev - } else { - this.prev = null - } - - if (next) { - next.prev = this - this.next = next - } else { - this.next = null - } -} - -try { - // add if support for Symbol.iterator is present - require('./iterator.js')(Yallist) -} catch (er) {} diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json index a41cc80aae14d..9a4a511239899 100644 --- a/node_modules/tar/package.json +++ b/node_modules/tar/package.json @@ -1,31 +1,33 @@ { - "_from": "tar@latest", - "_id": "tar@4.4.10", + "_from": "tar@4.4.12", + "_id": "tar@4.4.12", "_inBundle": false, - "_integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", + "_integrity": "sha512-4GwpJwdSjIHlUrWd/1yJrl63UqcqjJyVglgIwn4gcG+Lrp9TXpZ1ZRrGLIRBNqLTUvz6yoPJrX4B/MISxY/Ukg==", "_location": "/tar", "_phantomChildren": { - "safe-buffer": "5.1.2" + "safe-buffer": "5.1.2", + "yallist": "3.0.3" }, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "tar@latest", + "raw": "tar@4.4.12", "name": "tar", "escapedName": "tar", - "rawSpec": "latest", + "rawSpec": "4.4.12", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "4.4.12" }, "_requiredBy": [ "#USER", "/", + "/node-gyp", "/pacote" ], - "_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", - "_shasum": "946b2810b9a5e0b26140cf78bea6b0b0d689eba1", - "_spec": "tar@latest", - "_where": "/Users/isaacs/dev/npm/cli", + "_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.12.tgz", + "_shasum": "6a1275a870a782f92828e24d28fa6aa253193af7", + "_spec": "tar@4.4.12", + "_where": "/Users/mperrotte/npminc/cli", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -38,7 +40,7 @@ "dependencies": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.3.5", + "minipass": "^2.8.6", "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", @@ -52,7 +54,7 @@ "events-to-array": "^1.1.2", "mutate-fs": "^2.1.1", "rimraf": "^2.6.3", - "tap": "^14.2.0", + "tap": "^14.6.5", "tar-fs": "^1.16.3", "tar-stream": "^1.6.2" }, @@ -82,5 +84,5 @@ "coverage-map": "map.js", "check-coverage": true }, - "version": "4.4.10" + "version": "4.4.12" } diff --git a/package-lock.json b/package-lock.json index f2ab35e24f61b..2bc0f62454d12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2122,11 +2122,22 @@ "dev": true }, "fs-minipass": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", - "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", "requires": { - "minipass": "^2.2.1" + "minipass": "^2.6.0" + }, + "dependencies": { + "minipass": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.8.6.tgz", + "integrity": "sha512-lFG7d6g3+/UaFDCOtqPiKAC9zngWWsQZl1g5q6gaONqrjq61SX2xFqXMleQiFVyDpYwa018E9hmlAFY22PCb+A==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + } } }, "fs-vacuum": { @@ -3563,9 +3574,9 @@ } }, "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.2.tgz", + "integrity": "sha512-hR3At21uSrsjjDTWrbu0IMLTpnkpv8IIMFDFaoz43Tmu4LkmAXfH44vNNzpTnf+OAQQCHrb91y/wc2J4x5XgSQ==", "requires": { "minipass": "^2.2.1" } @@ -5848,13 +5859,13 @@ } }, "tar": { - "version": "4.4.10", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", - "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", + "version": "4.4.12", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.12.tgz", + "integrity": "sha512-4GwpJwdSjIHlUrWd/1yJrl63UqcqjJyVglgIwn4gcG+Lrp9TXpZ1ZRrGLIRBNqLTUvz6yoPJrX4B/MISxY/Ukg==", "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.3.5", + "minipass": "^2.8.6", "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", @@ -5862,18 +5873,13 @@ }, "dependencies": { "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.8.6.tgz", + "integrity": "sha512-lFG7d6g3+/UaFDCOtqPiKAC9zngWWsQZl1g5q6gaONqrjq61SX2xFqXMleQiFVyDpYwa018E9hmlAFY22PCb+A==", "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" } - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } }, diff --git a/package.json b/package.json index e8cfebb459f76..589c3f5701ebc 100644 --- a/package.json +++ b/package.json @@ -134,7 +134,7 @@ "sorted-union-stream": "~2.1.3", "ssri": "^6.0.1", "stringify-package": "^1.0.0", - "tar": "^4.4.10", + "tar": "^4.4.12", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "uid-number": "0.0.6", From fe83b8c82f4b77d8ee5b74fdc13f2d101343ddaf Mon Sep 17 00:00:00 2001 From: Michael Perrotte Date: Thu, 26 Sep 2019 14:59:21 -0400 Subject: [PATCH 05/27] docs: updated CHANGELOG for 6.12.0 --- CHANGELOG.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9b73d7a230d1..9c710a662cb44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ +## 6.12.0 (2019-10-01): + +Now `npm ci` runs prepare scripts for git dependencies, and respects the `--no-optional` argument. + +### BUG FIXES + +* [`890b245dc`](https://github.com/npm/cli/commit/890b245dc1f609590d8ab993fac7cf5a37ed46a5) + [#252](https://github.com/npm/cli/pull/252) + chore(ci): add dirPacker to options + ([@claudiahdz](https://github.com/claudiahdz)) + +### DEPENDENCIES + +* [`0ca063c5d`](https://github.com/npm/cli/commit/0ca063c5dc961c4aa17373f4b33fb54c51c8c8d6) + `npm-lifecycle@3.1.4`: + - fix: filter functions and undefined out of makeEnv ([@isaacs](https://github.com/isaacs)) +* [`5df6b0ea2`](https://github.com/npm/cli/commit/5df6b0ea2e3106ba65bba649cc8d7f02f4738236) + `libcipm@4.0.4`: + - fix: pack git directories properly ([@claudiahdz](https://github.com/claudiahdz)) + - respect no-optional argument ([@cruzdanilo](https://github.com/cruzdanilo)) +* [`7e04f728c`](https://github.com/npm/cli/commit/7e04f728cc4cd4853a8fc99e2df0a12988897589) + `tar@4.4.12` + + ## 6.11.3 (2019-09-03): Fix npm ci regressions and npm outdated depth. From 2199037848ee9961126873d4cc07cdc8cb9e1bcb Mon Sep 17 00:00:00 2001 From: Michael Perrotte Date: Thu, 26 Sep 2019 14:59:33 -0400 Subject: [PATCH 06/27] update AUTHORS --- AUTHORS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AUTHORS b/AUTHORS index bed059c08e193..a6ef0eb722bf7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -656,3 +656,5 @@ Olivier Chevet Maël Nison Sara Ahbabou Gareth Jones +Ruy Adorno +Michael Perrotte From eb22908593edf1a465208eca947539f5a9e921d4 Mon Sep 17 00:00:00 2001 From: Michael Perrotte Date: Thu, 26 Sep 2019 14:59:33 -0400 Subject: [PATCH 07/27] 6.12.0-next.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2bc0f62454d12..2ed835d8774e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "npm", - "version": "6.11.3", + "version": "6.12.0-next.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 589c3f5701ebc..8728bdaebe38e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "6.11.3", + "version": "6.12.0-next.0", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ From bee6d42c68733fb59d3698f5d80fb748901f2a60 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sun, 29 Sep 2019 00:04:38 -0700 Subject: [PATCH 08/27] node-gyp@5.0.4 PR-URL: https://github.com/npm/cli/pull/260 Credit: @isaacs Close: #260 Reviewed-by: @isaacs --- node_modules/node-gyp/.travis.yml | 16 +++-- node_modules/node-gyp/CHANGELOG.md | 24 +++++++ node_modules/node-gyp/README.md | 5 +- node_modules/node-gyp/gyp/gyp_main.py | 38 ++++++++++- .../node-gyp/gyp/pylib/gyp/MSVSNew.py | 2 +- .../gyp/pylib/gyp/MSVSSettings_test.py | 8 ++- node_modules/node-gyp/gyp/pylib/gyp/common.py | 26 ++++++- .../node-gyp/gyp/pylib/gyp/common_test.py | 8 +-- .../node-gyp/gyp/pylib/gyp/easy_xml.py | 4 +- .../node-gyp/gyp/pylib/gyp/easy_xml_test.py | 7 +- .../gyp/pylib/gyp/generator/analyzer.py | 6 +- .../gyp/pylib/gyp/generator/android.py | 2 +- .../node-gyp/gyp/pylib/gyp/generator/cmake.py | 4 +- .../gyp/pylib/gyp/generator/eclipse.py | 4 +- .../node-gyp/gyp/pylib/gyp/generator/make.py | 52 +++++++------- .../node-gyp/gyp/pylib/gyp/generator/msvs.py | 28 +++++--- .../gyp/pylib/gyp/generator/msvs_test.py | 7 +- .../node-gyp/gyp/pylib/gyp/generator/ninja.py | 9 ++- .../gyp/pylib/gyp/generator/ninja_test.py | 1 - .../node-gyp/gyp/pylib/gyp/generator/xcode.py | 12 ++-- node_modules/node-gyp/gyp/pylib/gyp/input.py | 68 +++++++++---------- .../node-gyp/gyp/pylib/gyp/msvs_emulation.py | 2 +- .../node-gyp/gyp/pylib/gyp/xcode_emulation.py | 32 +++++---- .../node-gyp/gyp/pylib/gyp/xcode_ninja.py | 2 +- .../node-gyp/gyp/pylib/gyp/xcodeproj_file.py | 2 +- node_modules/node-gyp/gyp/tools/pretty_gyp.py | 2 +- .../node-gyp/gyp/tools/pretty_vcproj.py | 2 +- node_modules/node-gyp/lib/build.js | 3 +- node_modules/node-gyp/lib/configure.js | 7 ++ node_modules/node-gyp/lib/install.js | 10 ++- node_modules/node-gyp/lib/list.js | 2 +- node_modules/node-gyp/package.json | 22 +++--- .../node-gyp/src/win_delay_load_hook.cc | 4 ++ .../node-gyp/test/test-find-python.js | 15 ++-- package-lock.json | 8 +-- package.json | 2 +- 36 files changed, 286 insertions(+), 160 deletions(-) diff --git a/node_modules/node-gyp/.travis.yml b/node_modules/node-gyp/.travis.yml index a6dd2dcf28b1e..f27f024f2d9a2 100644 --- a/node_modules/node-gyp/.travis.yml +++ b/node_modules/node-gyp/.travis.yml @@ -8,7 +8,7 @@ matrix: python: 2.7 - name: "Python 2.7 on macOS" os: osx - osx_image: xcode10.2 + osx_image: xcode11 language: shell # 'language: python' is not yet supported on macOS env: NODE_GYP_FORCE_PYTHON=python2 before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew install npm @@ -28,6 +28,7 @@ matrix: PATH=/c/Python27:/c/Python27/Scripts:$PATH NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe before_install: choco install python2 + - name: "Node.js 6 & Python 3.7 on Linux" python: 3.7 env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 @@ -44,6 +45,12 @@ matrix: python: 3.7 env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: nvm install 12 + - name: "Python 3.7 on macOS" + os: osx + #osx_image: xcode11 + language: shell # 'language: python' is not yet supported on macOS + env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 + before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew install npm - name: "Node.js 12 & Python 3.7 on Windows" os: windows language: node_js @@ -53,12 +60,7 @@ matrix: NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: choco install python - allow_failures: - - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 - - env: >- - PATH=/c/Python37:/c/Python37/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe - EXPERIMENTAL_NODE_GYP_PYTHON3=1 + install: #- pip install -r requirements.txt - pip install flake8 # pytest # add another testing frameworks later diff --git a/node_modules/node-gyp/CHANGELOG.md b/node_modules/node-gyp/CHANGELOG.md index 9a99ef2d0af40..3dbc5d9244eba 100644 --- a/node_modules/node-gyp/CHANGELOG.md +++ b/node_modules/node-gyp/CHANGELOG.md @@ -1,3 +1,27 @@ +v5.0.4 2019-09-27 +================= + +* [[`1236869ffc`](https://github.com/nodejs/node-gyp/commit/1236869ffc)] - **gyp**: modify XcodeVersion() to convert "4.2" to "0420" and "10.0" to "1000" (Christian Clauss) [#1895](https://github.com/nodejs/node-gyp/pull/1895) +* [[`36638afe48`](https://github.com/nodejs/node-gyp/commit/36638afe48)] - **gyp**: more decode stdout on Python 3 (cclauss) [#1894](https://github.com/nodejs/node-gyp/pull/1894) +* [[`f753c167c5`](https://github.com/nodejs/node-gyp/commit/f753c167c5)] - **gyp**: decode stdout on Python 3 (cclauss) [#1890](https://github.com/nodejs/node-gyp/pull/1890) +* [[`60a4083523`](https://github.com/nodejs/node-gyp/commit/60a4083523)] - **doc**: update xcode install instructions to match Node's BUILDING (Nhan Khong) [#1884](https://github.com/nodejs/node-gyp/pull/1884) +* [[`19dbc9ac32`](https://github.com/nodejs/node-gyp/commit/19dbc9ac32)] - **deps**: update tar to 4.4.12 (Matheus Marchini) [#1889](https://github.com/nodejs/node-gyp/pull/1889) +* [[`5f3ed92181`](https://github.com/nodejs/node-gyp/commit/5f3ed92181)] - **bin**: fix the usage instructions (Halit Ogunc) [#1888](https://github.com/nodejs/node-gyp/pull/1888) +* [[`aab118edf1`](https://github.com/nodejs/node-gyp/commit/aab118edf1)] - **lib**: adding keep-alive header to download requests (Milad Farazmand) [#1863](https://github.com/nodejs/node-gyp/pull/1863) +* [[`1186e89326`](https://github.com/nodejs/node-gyp/commit/1186e89326)] - **lib**: ignore non-critical os.userInfo() failures (Rod Vagg) [#1835](https://github.com/nodejs/node-gyp/pull/1835) +* [[`785e527c3d`](https://github.com/nodejs/node-gyp/commit/785e527c3d)] - **doc**: fix missing argument for setting python path (lagorsse) [#1802](https://github.com/nodejs/node-gyp/pull/1802) +* [[`a97615196c`](https://github.com/nodejs/node-gyp/commit/a97615196c)] - **gyp**: rm semicolons (Python != JavaScript) (MattIPv4) [#1858](https://github.com/nodejs/node-gyp/pull/1858) +* [[`06019bac24`](https://github.com/nodejs/node-gyp/commit/06019bac24)] - **gyp**: assorted typo fixes (XhmikosR) [#1853](https://github.com/nodejs/node-gyp/pull/1853) +* [[`3f4972c1ca`](https://github.com/nodejs/node-gyp/commit/3f4972c1ca)] - **gyp**: use "is" when comparing to None (Vladyslav Burzakovskyy) [#1860](https://github.com/nodejs/node-gyp/pull/1860) +* [[`1cb4708073`](https://github.com/nodejs/node-gyp/commit/1cb4708073)] - **src,win**: improve unmanaged handling (Peter Sabath) [#1852](https://github.com/nodejs/node-gyp/pull/1852) +* [[`5553cd910e`](https://github.com/nodejs/node-gyp/commit/5553cd910e)] - **gyp**: improve Windows+Cygwin compatibility (Jose Quijada) [#1817](https://github.com/nodejs/node-gyp/pull/1817) +* [[`8bcb1fbb43`](https://github.com/nodejs/node-gyp/commit/8bcb1fbb43)] - **gyp**: Python 3 Windows fixes (João Reis) [#1843](https://github.com/nodejs/node-gyp/pull/1843) +* [[`2e24d0a326`](https://github.com/nodejs/node-gyp/commit/2e24d0a326)] - **test**: accept Python 3 in test-find-python.js (João Reis) [#1843](https://github.com/nodejs/node-gyp/pull/1843) +* [[`1267b4dc1c`](https://github.com/nodejs/node-gyp/commit/1267b4dc1c)] - **build**: add test run Python 3.7 on macOS (Christian Clauss) [#1843](https://github.com/nodejs/node-gyp/pull/1843) +* [[`da1b031aa3`](https://github.com/nodejs/node-gyp/commit/da1b031aa3)] - **build**: import StringIO on Python 2 and Python 3 (Christian Clauss) [#1836](https://github.com/nodejs/node-gyp/pull/1836) +* [[`fa0ed4aa42`](https://github.com/nodejs/node-gyp/commit/fa0ed4aa42)] - **build**: more Python 3 compat, replace compile with ast (cclauss) [#1820](https://github.com/nodejs/node-gyp/pull/1820) +* [[`18d5c7c9d0`](https://github.com/nodejs/node-gyp/commit/18d5c7c9d0)] - **win,src**: update win\_delay\_load\_hook.cc to work with /clr (Ivan Petrovic) [#1819](https://github.com/nodejs/node-gyp/pull/1819) + v5.0.3 2019-07-17 ================= diff --git a/node_modules/node-gyp/README.md b/node_modules/node-gyp/README.md index b0900028d734d..0c76ffc09b4c0 100644 --- a/node_modules/node-gyp/README.md +++ b/node_modules/node-gyp/README.md @@ -35,8 +35,7 @@ You will also need to install: * `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) (already installed on macOS) * [Xcode](https://developer.apple.com/xcode/download/) - * You also need to install the `Command Line Tools` via Xcode. You can find this under the menu `Xcode -> Preferences -> Locations` (or by running `xcode-select --install` in your Terminal) - * This step will install `gcc` and the related toolchain containing `make` + * You also need to install the `XCode Command Line Tools` by running `xcode-select --install`. Alternatively, if you already have the full Xcode installed, you can find them under the menu `Xcode -> Open Developer Tool -> More Developer Tools...`. This step will install `clang`, `clang++`, and `make`. ### On Windows @@ -63,7 +62,7 @@ If you have multiple Python versions installed, you can identify which Python version `node-gyp` uses by setting the `--python` variable: ``` bash -$ node-gyp --python /path/to/python2.7 +$ node-gyp --python /path/to/executable/python2.7 ``` If `node-gyp` is called by way of `npm`, *and* you have multiple versions of diff --git a/node_modules/node-gyp/gyp/gyp_main.py b/node_modules/node-gyp/gyp/gyp_main.py index 25a6eba94aae7..aece53c8eb3b0 100755 --- a/node_modules/node-gyp/gyp/gyp_main.py +++ b/node_modules/node-gyp/gyp/gyp_main.py @@ -6,10 +6,44 @@ import os import sys +import subprocess + +PY3 = bytes != str + +# Below IsCygwin() function copied from pylib/gyp/common.py +def IsCygwin(): + try: + out = subprocess.Popen("uname", + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + stdout, stderr = out.communicate() + if PY3: + stdout = stdout.decode("utf-8") + return "CYGWIN" in str(stdout) + except Exception: + return False + + +def UnixifyPath(path): + try: + if not IsCygwin(): + return path + out = subprocess.Popen(["cygpath", "-u", path], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + stdout, stderr = out.communicate() + if PY3: + stdout = stdout.decode("utf-8") + return str(stdout) + except Exception: + return path + # Make sure we're using the version of pylib in this repo, not one installed -# elsewhere on the system. -sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), 'pylib')) +# elsewhere on the system. Also convert to Unix style path on Cygwin systems, +# else the 'gyp' library will not be found +path = UnixifyPath(sys.argv[0]) +sys.path.insert(0, os.path.join(os.path.dirname(path), 'pylib')) import gyp if __name__ == '__main__': diff --git a/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py b/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py index 0ec628cc1f759..9b64e2c1c8060 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py @@ -45,7 +45,7 @@ def MakeGuid(name, seed='msvs_new'): not change when the project for a target is rebuilt. """ # Calculate a MD5 signature for the seed and name. - d = hashlib.md5(str(seed) + str(name)).hexdigest().upper() + d = hashlib.md5((str(seed) + str(name)).encode('utf-8')).hexdigest().upper() # Convert most of the signature to GUID form (discard the rest) guid = ('{' + d[:8] + '-' + d[8:12] + '-' + d[12:16] + '-' + d[16:20] + '-' + d[20:32] + '}') diff --git a/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py b/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py index bf6ea6b802ff9..c082bbea9b41d 100755 --- a/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py @@ -6,7 +6,11 @@ """Unit tests for the MSVSSettings.py file.""" -import StringIO +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO + import unittest import gyp.MSVSSettings as MSVSSettings @@ -14,7 +18,7 @@ class TestSequenceFunctions(unittest.TestCase): def setUp(self): - self.stderr = StringIO.StringIO() + self.stderr = StringIO() def _ExpectedWarnings(self, expected): """Compares recorded lines to expected warnings.""" diff --git a/node_modules/node-gyp/gyp/pylib/gyp/common.py b/node_modules/node-gyp/gyp/pylib/gyp/common.py index 834a8e6c95199..071ad7e242c2e 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/common.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/common.py @@ -9,6 +9,9 @@ import re import tempfile import sys +import subprocess + +PY3 = bytes != str # A minimal memoizing decorator. It'll blow up if the args aren't immutable, @@ -337,11 +340,16 @@ def WriteOnDiff(filename): class Writer(object): """Wrapper around file which only covers the target if it differs.""" def __init__(self): + # On Cygwin remove the "dir" argument because `C:` prefixed paths are treated as relative, + # consequently ending up with current dir "/cygdrive/c/..." being prefixed to those, which was + # obviously a non-existent path, for example: "/cygdrive/c//C:\". + # See https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp for more details + base_temp_dir = "" if IsCygwin() else os.path.dirname(filename) # Pick temporary file. tmp_fd, self.tmp_path = tempfile.mkstemp( suffix='.tmp', prefix=os.path.split(filename)[1] + '.gyp.', - dir=os.path.split(filename)[0]) + dir=base_temp_dir) try: self.tmp_file = os.fdopen(tmp_fd, 'wb') except Exception: @@ -394,6 +402,9 @@ def close(self): os.unlink(self.tmp_path) raise + def write(self, s): + self.tmp_file.write(s.encode('utf-8')) + return Writer() @@ -608,3 +619,16 @@ def CrossCompileRequested(): os.environ.get('AR_target') or os.environ.get('CC_target') or os.environ.get('CXX_target')) + +def IsCygwin(): + try: + out = subprocess.Popen("uname", + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + stdout, stderr = out.communicate() + if PY3: + stdout = stdout.decode("utf-8") + return "CYGWIN" in str(stdout) + except Exception: + return False + diff --git a/node_modules/node-gyp/gyp/pylib/gyp/common_test.py b/node_modules/node-gyp/gyp/pylib/gyp/common_test.py index ad6f9a1438f30..b75bbb8412b6f 100755 --- a/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/common_test.py @@ -59,10 +59,10 @@ def test_platform_default(self): self.assertFlavor('freebsd', 'freebsd9' , {}) self.assertFlavor('freebsd', 'freebsd10', {}) self.assertFlavor('openbsd', 'openbsd5' , {}) - self.assertFlavor('solaris', 'sunos5' , {}); - self.assertFlavor('solaris', 'sunos' , {}); - self.assertFlavor('linux' , 'linux2' , {}); - self.assertFlavor('linux' , 'linux3' , {}); + self.assertFlavor('solaris', 'sunos5' , {}) + self.assertFlavor('solaris', 'sunos' , {}) + self.assertFlavor('linux' , 'linux2' , {}) + self.assertFlavor('linux' , 'linux3' , {}) def test_param(self): self.assertFlavor('foobar', 'linux2' , {'flavor': 'foobar'}) diff --git a/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py b/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py index 7c3f621f1faff..1ddd9091756a2 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py @@ -120,7 +120,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False, default_encoding = locale.getdefaultlocale()[1] if default_encoding.upper() != encoding.upper(): - xml_string = xml_string.decode(default_encoding).encode(encoding) + xml_string = xml_string.encode(encoding) # Get the old content try: @@ -132,7 +132,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False, # It has changed, write it if existing != xml_string: - f = open(path, 'w') + f = open(path, 'wb') f.write(xml_string) f.close() diff --git a/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py b/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py index df64354982c01..2a80b8a4564aa 100755 --- a/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py @@ -8,13 +8,16 @@ import gyp.easy_xml as easy_xml import unittest -import StringIO +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO class TestSequenceFunctions(unittest.TestCase): def setUp(self): - self.stderr = StringIO.StringIO() + self.stderr = StringIO() def test_EasyXml_simple(self): self.assertEqual( diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py index dc17c96524fdd..59d73dbedbd31 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py @@ -615,7 +615,7 @@ def _supplied_target_names(self): def _supplied_target_names_no_all(self): """Returns the supplied test targets without 'all'.""" - result = self._supplied_target_names(); + result = self._supplied_target_names() result.discard('all') return result @@ -668,10 +668,10 @@ def find_matching_test_target_names(self): def find_matching_compile_target_names(self): """Returns the set of output compile targets.""" - assert self.is_build_impacted(); + assert self.is_build_impacted() # Compile targets are found by searching up from changed targets. # Reset the visited status for _GetBuildTargets. - for target in self._name_to_target.itervalues(): + for target in self._name_to_target.values(): target.visited = False supplied_targets = _LookupTargets(self._supplied_target_names_no_all(), diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py index b7f98428881af..cecb28c3660b5 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py @@ -550,7 +550,7 @@ def WriteSources(self, spec, configs, extra_sources): # to work properly. If the file has the wrong C++ extension, then we add # a rule to copy that to intermediates and use the new version. final_generated_sources = [] - # If a source file gets copied, we still need to add the orginal source + # If a source file gets copied, we still need to add the original source # directory as header search path, for GCC searches headers in the # directory that contains the source file by default. origin_src_dirs = [] diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py index 7aabddb6331c6..996b6f25fdb01 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py @@ -574,7 +574,7 @@ class CMakeNamer(object): """Converts Gyp target names into CMake target names. CMake requires that target names be globally unique. One way to ensure - this is to fully qualify the names of the targets. Unfortunatly, this + this is to fully qualify the names of the targets. Unfortunately, this ends up with all targets looking like "chrome_chrome_gyp_chrome" instead of just "chrome". If this generator were only interested in building, it would be possible to fully qualify all target names, then create @@ -681,7 +681,7 @@ def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use, for src in srcs: _, ext = os.path.splitext(src) src_type = COMPILABLE_EXTENSIONS.get(ext, None) - src_norm_path = NormjoinPath(path_from_cmakelists_to_gyp, src); + src_norm_path = NormjoinPath(path_from_cmakelists_to_gyp, src) if src_type == 's': s_sources.append(src_norm_path) diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py index b7c6aa951fd13..6b49ad6760051 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py @@ -195,7 +195,7 @@ def GetAllDefines(target_list, target_dicts, data, config_name, params, """Calculate the defines for a project. Returns: - A dict that includes explict defines declared in gyp files along with all of + A dict that includes explicit defines declared in gyp files along with all of the default defines that the compiler uses. """ @@ -272,7 +272,7 @@ def WriteMacros(out, eclipse_langs, defines): out.write(' \n') for lang in eclipse_langs: out.write(' \n' % lang) - for key in sorted(defines.iterkeys()): + for key in sorted(defines): out.write(' %s%s\n' % (escape(key), escape(defines[key]))) out.write(' \n') diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py index 37ac255bfa66d..bdf7134537022 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py @@ -12,7 +12,7 @@ # all are sourced by the top-level Makefile. This means that all # variables in .mk-files clobber one another. Be careful to use := # where appropriate for immediate evaluation, and similarly to watch -# that you're not relying on a variable value to last beween different +# that you're not relying on a variable value to last between different # .mk files. # # TODOs: @@ -821,7 +821,7 @@ def Write(self, qualified_target, base_path, output_filename, spec, configs, gyp.xcode_emulation.MacPrefixHeader( self.xcode_settings, lambda p: Sourceify(self.Absolutify(p)), self.Pchify)) - sources = filter(Compilable, all_sources) + sources = list(filter(Compilable, all_sources)) if sources: self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT1) extensions = set([os.path.splitext(s)[1] for s in sources]) @@ -950,7 +950,7 @@ def WriteActions(self, actions, extra_sources, extra_outputs, '%s%s' % (name, cd_action, command)) self.WriteLn() - outputs = map(self.Absolutify, outputs) + outputs = [self.Absolutify(output) for output in outputs] # The makefile rules are all relative to the top dir, but the gyp actions # are defined relative to their containing dir. This replaces the obj # variable for the action rule with an absolute version so that the output @@ -974,7 +974,7 @@ def WriteActions(self, actions, extra_sources, extra_outputs, outputs = [gyp.xcode_emulation.ExpandEnvVars(o, env) for o in outputs] inputs = [gyp.xcode_emulation.ExpandEnvVars(i, env) for i in inputs] - self.WriteDoCmd(outputs, map(Sourceify, map(self.Absolutify, inputs)), + self.WriteDoCmd(outputs, [Sourceify(self.Absolutify(i)) for i in inputs], part_of_all=part_of_all, command=name) # Stuff the outputs in a variable so we can refer to them later. @@ -1023,8 +1023,8 @@ def WriteRules(self, rules, extra_sources, extra_outputs, extra_sources += outputs if int(rule.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += outputs - inputs = map(Sourceify, map(self.Absolutify, [rule_source] + - rule.get('inputs', []))) + inputs = [Sourceify(self.Absolutify(i)) for i + in [rule_source] + rule.get('inputs', [])] actions = ['$(call do_cmd,%s_%d)' % (name, count)] if name == 'resources_grit': @@ -1040,7 +1040,7 @@ def WriteRules(self, rules, extra_sources, extra_outputs, outputs = [gyp.xcode_emulation.ExpandEnvVars(o, env) for o in outputs] inputs = [gyp.xcode_emulation.ExpandEnvVars(i, env) for i in inputs] - outputs = map(self.Absolutify, outputs) + outputs = [self.Absolutify(output) for output in outputs] all_outputs += outputs # Only write the 'obj' and 'builddir' rules for the "primary" output # (:1); it's superfluous for the "extra outputs", and this avoids @@ -1147,7 +1147,7 @@ def WriteCopies(self, copies, extra_outputs, part_of_all): path = gyp.xcode_emulation.ExpandEnvVars(path, env) self.WriteDoCmd([output], [path], 'copy', part_of_all) outputs.append(output) - self.WriteLn('%s = %s' % (variable, ' '.join(map(QuoteSpaces, outputs)))) + self.WriteLn('%s = %s' % (variable, ' '.join(QuoteSpaces(o) for o in outputs))) extra_outputs.append('$(%s)' % variable) self.WriteLn() @@ -1158,7 +1158,7 @@ def WriteMacBundleResources(self, resources, bundle_deps): for output, res in gyp.xcode_emulation.GetMacBundleResources( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, - map(Sourceify, map(self.Absolutify, resources))): + [Sourceify(self.Absolutify(r)) for r in resources]): _, ext = os.path.splitext(output) if ext != '.xcassets': # Make does not supports '.xcassets' emulation. @@ -1225,24 +1225,24 @@ def WriteSources(self, configs, deps, sources, cflags_c = config.get('cflags_c') cflags_cc = config.get('cflags_cc') - self.WriteLn("# Flags passed to all source files."); + self.WriteLn("# Flags passed to all source files.") self.WriteList(cflags, 'CFLAGS_%s' % configname) - self.WriteLn("# Flags passed to only C files."); + self.WriteLn("# Flags passed to only C files.") self.WriteList(cflags_c, 'CFLAGS_C_%s' % configname) - self.WriteLn("# Flags passed to only C++ files."); + self.WriteLn("# Flags passed to only C++ files.") self.WriteList(cflags_cc, 'CFLAGS_CC_%s' % configname) if self.flavor == 'mac': - self.WriteLn("# Flags passed to only ObjC files."); + self.WriteLn("# Flags passed to only ObjC files.") self.WriteList(cflags_objc, 'CFLAGS_OBJC_%s' % configname) - self.WriteLn("# Flags passed to only ObjC++ files."); + self.WriteLn("# Flags passed to only ObjC++ files.") self.WriteList(cflags_objcc, 'CFLAGS_OBJCC_%s' % configname) includes = config.get('include_dirs') if includes: - includes = map(Sourceify, map(self.Absolutify, includes)) + includes = [Sourceify(self.Absolutify(i)) for i in includes] self.WriteList(includes, 'INCS_%s' % configname, prefix='-I') - compilable = filter(Compilable, sources) - objs = map(self.Objectify, map(self.Absolutify, map(Target, compilable))) + compilable = list(filter(Compilable, sources)) + objs = [self.Objectify(self.Absolutify(Target(c))) for c in compilable] self.WriteList(objs, 'OBJS') for obj in objs: @@ -1314,7 +1314,7 @@ def WriteSources(self, configs, deps, sources, # If there are any object files in our input file list, link them into our # output. - extra_link_deps += filter(Linkable, sources) + extra_link_deps += list(filter(Linkable, sources)) self.WriteLn() @@ -1564,7 +1564,7 @@ def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps, # Bundle dependencies. Note that the code below adds actions to this # target, so if you move these two lines, move the lines below as well. - self.WriteList(map(QuoteSpaces, bundle_deps), 'BUNDLE_DEPS') + self.WriteList([QuoteSpaces(dep) for dep in bundle_deps], 'BUNDLE_DEPS') self.WriteLn('%s: $(BUNDLE_DEPS)' % QuoteSpaces(self.output)) # After the framework is built, package it. Needs to happen before @@ -1598,7 +1598,7 @@ def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps, if self.type == 'executable': self.WriteLn('%s: LD_INPUTS := %s' % ( QuoteSpaces(self.output_binary), - ' '.join(map(QuoteSpaces, link_deps)))) + ' '.join(QuoteSpaces(dep) for dep in link_deps))) if self.toolset == 'host' and self.flavor == 'android': self.WriteDoCmd([self.output_binary], link_deps, 'link_host', part_of_all, postbuilds=postbuilds) @@ -1620,7 +1620,7 @@ def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps, elif self.type == 'shared_library': self.WriteLn('%s: LD_INPUTS := %s' % ( QuoteSpaces(self.output_binary), - ' '.join(map(QuoteSpaces, link_deps)))) + ' '.join(QuoteSpaces(dep) for dep in link_deps))) self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all, postbuilds=postbuilds) elif self.type == 'loadable_module': @@ -1746,8 +1746,8 @@ def WriteMakeRule(self, outputs, inputs, actions=None, comment=None, output is just a name to run the rule command: (optional) command name to generate unambiguous labels """ - outputs = map(QuoteSpaces, outputs) - inputs = map(QuoteSpaces, inputs) + outputs = [QuoteSpaces(o) for o in outputs] + inputs = [QuoteSpaces(i) for i in inputs] if comment: self.WriteLn('# ' + comment) @@ -1779,7 +1779,7 @@ def WriteMakeRule(self, outputs, inputs, actions=None, comment=None, cmddigest = hashlib.sha1(command if command else self.target).hexdigest() intermediate = "%s.intermediate" % cmddigest self.WriteLn('%s: %s' % (' '.join(outputs), intermediate)) - self.WriteLn('\t%s' % '@:'); + self.WriteLn('\t%s' % '@:') self.WriteLn('%s: %s' % ('.INTERMEDIATE', intermediate)) self.WriteLn('%s: %s%s' % (intermediate, ' '.join(inputs), force_append)) @@ -1836,7 +1836,7 @@ def WriteAndroidNdkModuleRule(self, module_name, all_sources, link_deps): default_cpp_ext = ext self.WriteLn('LOCAL_CPP_EXTENSION := ' + default_cpp_ext) - self.WriteList(map(self.Absolutify, filter(Compilable, all_sources)), + self.WriteList(list(map(self.Absolutify, filter(Compilable, all_sources))), 'LOCAL_SRC_FILES') # Filter out those which do not match prefix and suffix and produce @@ -1979,7 +1979,7 @@ def WriteAutoRegenerationRule(params, root_makefile, makefile_name, "%(makefile_name)s: %(deps)s\n" "\t$(call do_cmd,regen_makefile)\n\n" % { 'makefile_name': makefile_name, - 'deps': ' '.join(map(SourceifyAndQuoteSpaces, build_files)), + 'deps': ' '.join(SourceifyAndQuoteSpaces(bf) for bf in build_files), 'cmd': gyp.common.EncodePOSIXShellList( [gyp_binary, '-fmake'] + gyp.RegenerateFlags(options) + diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py index aacbe608360e9..b3b4bc105366e 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py @@ -165,7 +165,7 @@ def _FixPath(path): Returns: The path with all slashes made into backslashes. """ - if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$': + if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$' and not _IsWindowsAbsPath(path): path = os.path.join(fixpath_prefix, path) path = path.replace('/', '\\') path = _NormalizedSource(path) @@ -174,6 +174,16 @@ def _FixPath(path): return path +def _IsWindowsAbsPath(path): + """ + On Cygwin systems Python needs a little help determining if a path is an absolute Windows path or not, so that + it does not treat those as relative, which results in bad paths like: + + '..\C:\\some_source_code_file.cc' + """ + return path.startswith('c:') or path.startswith('C:') + + def _FixPaths(paths): """Fix each of the paths of the list.""" return [_FixPath(i) for i in paths] @@ -1753,8 +1763,8 @@ def _CollapseSingles(parent, node): # such projects up one level. if (type(node) == dict and len(node) == 1 and - node.keys()[0] == parent + '.vcproj'): - return node[node.keys()[0]] + list(node)[0] == parent + '.vcproj'): + return node[list(node)[0]] if type(node) != dict: return node for child in node: @@ -1773,8 +1783,8 @@ def _GatherSolutionFolders(sln_projects, project_objects, flat): # Walk down from the top until we hit a folder that has more than one entry. # In practice, this strips the top-level "src/" dir from the hierarchy in # the solution. - while len(root) == 1 and type(root[root.keys()[0]]) == dict: - root = root[root.keys()[0]] + while len(root) == 1 and type(root[list(root)[0]]) == dict: + root = root[list(root)[0]] # Collapse singles. root = _CollapseSingles('', root) # Merge buckets until everything is a root entry. @@ -2691,7 +2701,7 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name): platform_name = None msvs_windows_target_platform_version = None - for configuration in spec['configurations'].itervalues(): + for configuration in spec['configurations'].values(): platform_name = platform_name or _ConfigPlatform(configuration) msvs_windows_target_platform_version = \ msvs_windows_target_platform_version or \ @@ -3059,7 +3069,7 @@ def _FinalizeMSBuildSettings(spec, configuration): _ToolAppend(msbuild_settings, 'ResourceCompile', 'AdditionalIncludeDirectories', resource_include_dirs) # Add in libraries, note that even for empty libraries, we want this - # set, to prevent inheriting default libraries from the enviroment. + # set, to prevent inheriting default libraries from the environment. _ToolSetOrAppend(msbuild_settings, 'Link', 'AdditionalDependencies', libraries) _ToolAppend(msbuild_settings, 'Link', 'AdditionalLibraryDirectories', @@ -3252,7 +3262,7 @@ def _GetMSBuildProjectReferences(project): ['Project', guid], ['ReferenceOutputAssembly', 'false'] ] - for config in dependency.spec.get('configurations', {}).itervalues(): + for config in dependency.spec.get('configurations', {}).values(): if config.get('msvs_use_library_dependency_inputs', 0): project_ref.append(['UseLibraryDependencyInputs', 'true']) break @@ -3321,7 +3331,7 @@ def _GenerateMSBuildProject(project, options, version, generator_flags): extension_to_rule_name, _GetUniquePlatforms(spec)) missing_sources = _VerifySourcesExist(sources, project_dir) - for configuration in configurations.itervalues(): + for configuration in configurations.values(): _FinalizeMSBuildSettings(spec, configuration) # Add attributes to root element diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py index c0b021df502bf..daf4f411bc481 100755 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py @@ -7,13 +7,16 @@ import gyp.generator.msvs as msvs import unittest -import StringIO +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO class TestSequenceFunctions(unittest.TestCase): def setUp(self): - self.stderr = StringIO.StringIO() + self.stderr = StringIO() def test_GetLibraries(self): self.assertEqual( diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py index aae5b71310445..33cc253aba67b 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py @@ -19,7 +19,10 @@ import gyp.msvs_emulation import gyp.MSVSUtil as MSVSUtil import gyp.xcode_emulation -from cStringIO import StringIO +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO from gyp.common import GetEnvironFallback import gyp.ninja_syntax as ninja_syntax @@ -723,7 +726,7 @@ def cygwin_munge(path): elif var == 'name': extra_bindings.append(('name', cygwin_munge(basename))) else: - assert var == None, repr(var) + assert var is None, repr(var) outputs = [self.GypPathToNinja(o, env) for o in outputs] if self.flavor == 'win': @@ -1818,7 +1821,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, # - The priority from low to high is gcc/g++, the 'make_global_settings' in # gyp, the environment variable. # - If there is no 'make_global_settings' for CC.host/CXX.host or - # 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set + # 'CC_host'/'CXX_host' environment variable, cc_host/cxx_host should be set # to cc/cxx. if flavor == 'win': ar = 'lib.exe' diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py index 1767b2f45a04c..1ad68e4fc9f07 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py @@ -8,7 +8,6 @@ import gyp.generator.ninja as ninja import unittest -import StringIO import sys import TestCommon diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py index 694a28afb122a..6317d04c70302 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py @@ -246,7 +246,7 @@ def Finalize1(self, xcode_targets, serialize_all_tests): targets_for_all.append(xcode_target) if target_name.lower() == 'all': - has_custom_all = True; + has_custom_all = True # If this target has a 'run_as' attribute, add its target to the # targets, and add it to the test targets. @@ -539,7 +539,7 @@ def ExpandXcodeVariables(string, expansions): """ matches = _xcode_variable_re.findall(string) - if matches == None: + if matches is None: return string matches.reverse() @@ -637,7 +637,7 @@ def GenerateOutput(target_list, target_dicts, data, params): pbxp = xcp.project # Set project-level attributes from multiple options - project_attributes = {}; + project_attributes = {} if parallel_builds: project_attributes['BuildIndependentTargetsInParallel'] = 'YES' if upgrade_check_project_version: @@ -776,7 +776,7 @@ def GenerateOutput(target_list, target_dicts, data, params): # logic all happens in ninja. Don't bother creating the extra targets in # that case. if type != 'none' and (spec_actions or spec_rules) and not ninja_wrapper: - support_xccl = CreateXCConfigurationList(configuration_names); + support_xccl = CreateXCConfigurationList(configuration_names) support_target_suffix = generator_flags.get( 'support_target_suffix', ' Support') support_target_properties = { @@ -998,7 +998,7 @@ def GenerateOutput(target_list, target_dicts, data, params): actions.append(action) if len(concrete_outputs_all) > 0: - # TODO(mark): There's a possibilty for collision here. Consider + # TODO(mark): There's a possibility for collision here. Consider # target "t" rule "A_r" and target "t_A" rule "r". makefile_name = '%s.make' % re.sub( '[^a-zA-Z0-9_]', '_' , '%s_%s' % (target_name, rule['rule_name'])) @@ -1171,7 +1171,7 @@ def GenerateOutput(target_list, target_dicts, data, params): dest = '$(SRCROOT)/' + dest code_sign = int(copy_group.get('xcode_code_sign', 0)) - settings = (None, '{ATTRIBUTES = (CodeSignOnCopy, ); }')[code_sign]; + settings = (None, '{ATTRIBUTES = (CodeSignOnCopy, ); }')[code_sign] # Coalesce multiple "copies" sections in the same target with the same # "destination" property into the same PBXCopyFilesBuildPhase, otherwise diff --git a/node_modules/node-gyp/gyp/pylib/gyp/input.py b/node_modules/node-gyp/gyp/pylib/gyp/input.py index eb9858f0c808f..aba81cf6542e0 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/input.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/input.py @@ -4,14 +4,8 @@ from __future__ import print_function -from compiler.ast import Const -from compiler.ast import Dict -from compiler.ast import Discard -from compiler.ast import List -from compiler.ast import Module -from compiler.ast import Node -from compiler.ast import Stmt -import compiler +import ast + import gyp.common import gyp.simple_copy import multiprocessing @@ -161,7 +155,7 @@ def GetIncludedBuildFiles(build_file_path, aux_data, included=None): in the list will be relative to the current directory. """ - if included == None: + if included is None: included = [] if build_file_path in included: @@ -184,43 +178,39 @@ def CheckedEval(file_contents): Note that this is slower than eval() is. """ - ast = compiler.parse(file_contents) - assert isinstance(ast, Module) - c1 = ast.getChildren() - assert c1[0] is None - assert isinstance(c1[1], Stmt) - c2 = c1[1].getChildren() - assert isinstance(c2[0], Discard) - c3 = c2[0].getChildren() - assert len(c3) == 1 - return CheckNode(c3[0], []) + syntax_tree = ast.parse(file_contents) + assert isinstance(syntax_tree, ast.Module) + c1 = syntax_tree.body + assert len(c1) == 1 + c2 = c1[0] + assert isinstance(c2, ast.Expr) + return CheckNode(c2.value, []) def CheckNode(node, keypath): - if isinstance(node, Dict): + if isinstance(node, ast.Dict): c = node.getChildren() dict = {} - for n in range(0, len(c), 2): - assert isinstance(c[n], Const) - key = c[n].getChildren()[0] + for key, value in zip(node.keys, node.values): + assert isinstance(key, ast.Str) + key = key.s if key in dict: raise GypError("Key '" + key + "' repeated at level " + repr(len(keypath) + 1) + " with key path '" + '.'.join(keypath) + "'") kp = list(keypath) # Make a copy of the list for descending this node. kp.append(key) - dict[key] = CheckNode(c[n + 1], kp) + dict[key] = CheckNode(value, kp) return dict - elif isinstance(node, List): - c = node.getChildren() + elif isinstance(node, ast.List): children = [] - for index, child in enumerate(c): + for index, child in enumerate(node.elts): kp = list(keypath) # Copy list. kp.append(repr(index)) children.append(CheckNode(child, kp)) return children - elif isinstance(node, Const): - return node.getChildren()[0] + elif isinstance(node, ast.Str): + return node.s else: raise TypeError("Unknown AST node at key path '" + '.'.join(keypath) + "': " + repr(node)) @@ -954,8 +944,12 @@ def ExpandVariables(input, phase, variables, build_file): else: replacement = variables[contents] + if isinstance(replacement, bytes) and not isinstance(replacement, str): + replacement = replacement.decode("utf-8") # done on Python 3 only if type(replacement) is list: for item in replacement: + if isinstance(item, bytes) and not isinstance(item, str): + item = item.decode("utf-8") # done on Python 3 only if not contents[-1] == '/' and type(item) not in (str, int): raise GypError('Variable ' + contents + ' must expand to a string or list of strings; ' + @@ -1068,7 +1062,7 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file): else: false_dict = None i = i + 2 - if result == None: + if result is None: result = EvalSingleCondition( cond_expr, true_dict, false_dict, phase, variables, build_file) @@ -1079,7 +1073,7 @@ def EvalSingleCondition( cond_expr, true_dict, false_dict, phase, variables, build_file): """Returns true_dict if cond_expr evaluates to true, and false_dict otherwise.""" - # Do expansions on the condition itself. Since the conditon can naturally + # Do expansions on the condition itself. Since the condition can naturally # contain variable references without needing to resort to GYP expansion # syntax, this is of dubious value for variables, but someone might want to # use a command expansion directly inside a condition. @@ -1184,7 +1178,7 @@ def LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key): continue if the_dict_key == 'variables' and variable_name in the_dict: # If the variable is set without a % in the_dict, and the_dict is a - # variables dict (making |variables| a varaibles sub-dict of a + # variables dict (making |variables| a variables sub-dict of a # variables dict), use the_dict's definition. value = the_dict[variable_name] else: @@ -1609,7 +1603,7 @@ def Visit(node, path): def DirectDependencies(self, dependencies=None): """Returns a list of just direct dependencies.""" - if dependencies == None: + if dependencies is None: dependencies = [] for dependency in self.dependencies: @@ -1637,7 +1631,7 @@ def _AddImportedDependencies(self, targets, dependencies=None): public entry point. """ - if dependencies == None: + if dependencies is None: dependencies = [] index = 0 @@ -1847,7 +1841,7 @@ def VerifyNoGYPFileCircularDependencies(targets): # Create a DependencyGraphNode for each gyp file containing a target. Put # it into a dict for easy access. dependency_nodes = {} - for target in targets.iterkeys(): + for target in targets: build_file = gyp.common.BuildFile(target) if not build_file in dependency_nodes: dependency_nodes[build_file] = DependencyGraphNode(build_file) @@ -1870,7 +1864,7 @@ def VerifyNoGYPFileCircularDependencies(targets): continue dependency_node = dependency_nodes.get(dependency_build_file) if not dependency_node: - raise GypError("Dependancy '%s' not found" % dependency_build_file) + raise GypError("Dependency '%s' not found" % dependency_build_file) if dependency_node not in build_file_node.dependencies: build_file_node.dependencies.append(dependency_node) dependency_node.dependents.append(build_file_node) @@ -1878,7 +1872,7 @@ def VerifyNoGYPFileCircularDependencies(targets): # Files that have no dependencies are treated as dependent on root_node. root_node = DependencyGraphNode(None) - for build_file_node in dependency_nodes.itervalues(): + for build_file_node in dependency_nodes.values(): if len(build_file_node.dependencies) == 0: build_file_node.dependencies.append(root_node) root_node.dependents.append(build_file_node) diff --git a/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py b/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py index 4a50b1b74c5c5..9d50bad1f558c 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py @@ -375,7 +375,7 @@ def GetCompilerPdbName(self, config, expand_special): return pdbname def GetMapFileName(self, config, expand_special): - """Gets the explicitly overriden map file name for a target or returns None + """Gets the explicitly overridden map file name for a target or returns None if it's not set.""" config = self._TargetConfig(config) map_file = self._Setting(('VCLinkerTool', 'MapFileName'), config) diff --git a/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py b/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py index 6ae41e293afd9..70f41e6bb4c17 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py @@ -20,6 +20,8 @@ import tempfile from gyp.common import GypError +PY3 = bytes != str + # Populated lazily by XcodeVersion, for efficiency, and to fix an issue when # "xcodebuild" is called too quickly (it has been found to return incorrect # version number). @@ -778,7 +780,7 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None): product_dir: The directory where products such static and dynamic libraries are placed. This is added to the library search path. gyp_to_build_path: A function that converts paths relative to the - current gyp file to paths relative to the build direcotry. + current gyp file to paths relative to the build directory. """ self.configname = configname ldflags = [] @@ -923,7 +925,7 @@ def GetPerTargetSetting(self, setting, default=None): def _GetStripPostbuilds(self, configname, output_binary, quiet): """Returns a list of shell commands that contain the shell commands - neccessary to strip this target's binary. These should be run as postbuilds + necessary to strip this target's binary. These should be run as postbuilds before the actual postbuilds run.""" self.configname = configname @@ -957,7 +959,7 @@ def _GetStripPostbuilds(self, configname, output_binary, quiet): def _GetDebugInfoPostbuilds(self, configname, output, output_binary, quiet): """Returns a list of shell commands that contain the shell commands - neccessary to massage this target's debug information. These should be run + necessary to massage this target's debug information. These should be run as postbuilds before the actual postbuilds run.""" self.configname = configname @@ -1052,7 +1054,7 @@ def _AdjustLibrary(self, library, config_name=None): # "/usr/lib" libraries, is do "-L/usr/lib -lname" which is dependent on the # library order and cause collision when building Chrome. # - # Instead substitude ".tbd" to ".dylib" in the generated project when the + # Instead substitute ".tbd" to ".dylib" in the generated project when the # following conditions are both true: # - library is referenced in the gyp file as "$(SDKROOT)/**/*.dylib", # - the ".dylib" file does not exists but a ".tbd" file do. @@ -1277,16 +1279,16 @@ def XcodeVersion(): except: version = CLTVersion() if version: - version = re.match(r'(\d+\.\d+\.?\d*)', version).groups()[0] + version = ".".join(version.split(".")[:3]) else: raise GypError("No Xcode or CLT version detected!") # The CLT has no build information, so we return an empty string. version_list = [version, ''] version = version_list[0] build = version_list[-1] - # Be careful to convert "4.2" to "0420": - version = version.split()[-1].replace('.', '') - version = (version + '0' * (3 - len(version))).zfill(4) + # Be careful to convert "4.2" to "0420" and "10.0" to "1000": + version = format(''.join((version.split()[-1].split('.') + ['0', '0'])[:3]), + '>04s') if build: build = build.split()[-1] XCODE_VERSION_CACHE = (version, build) @@ -1322,6 +1324,8 @@ def GetStdoutQuiet(cmdlist): Raises |GypError| if the command return with a non-zero return code.""" job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out = job.communicate()[0] + if PY3: + out = out.decode("utf-8") if job.returncode != 0: raise GypError('Error %d running %s' % (job.returncode, cmdlist[0])) return out.rstrip('\n') @@ -1332,6 +1336,8 @@ def GetStdout(cmdlist): Raises |GypError| if the command return with a non-zero return code.""" job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE) out = job.communicate()[0] + if PY3: + out = out.decode("utf-8") if job.returncode != 0: sys.stderr.write(out + '\n') raise GypError('Error %d running %s' % (job.returncode, cmdlist[0])) @@ -1341,7 +1347,7 @@ def GetStdout(cmdlist): def MergeGlobalXcodeSettingsToSpec(global_dict, spec): """Merges the global xcode_settings dictionary into each configuration of the target represented by spec. For keys that are both in the global and the local - xcode_settings dict, the local key gets precendence. + xcode_settings dict, the local key gets precedence. """ # The xcode generator special-cases global xcode_settings and does something # that amounts to merging in the global xcode_settings into each local @@ -1384,7 +1390,7 @@ def GetMacBundleResources(product_dir, xcode_settings, resources): output = dest # The make generator doesn't support it, so forbid it everywhere - # to keep the generators more interchangable. + # to keep the generators more interchangeable. assert ' ' not in res, ( "Spaces in resource filenames not supported (%s)" % res) @@ -1426,14 +1432,14 @@ def GetMacInfoPlist(product_dir, xcode_settings, gyp_path_to_build_path): relative to the build directory. xcode_settings: The XcodeSettings of the current target. gyp_to_build_path: A function that converts paths relative to the - current gyp file to paths relative to the build direcotry. + current gyp file to paths relative to the build directory. """ info_plist = xcode_settings.GetPerTargetSetting('INFOPLIST_FILE') if not info_plist: return None, None, [], {} # The make generator doesn't support it, so forbid it everywhere - # to keep the generators more interchangable. + # to keep the generators more interchangeable. assert ' ' not in info_plist, ( "Spaces in Info.plist filenames not supported (%s)" % info_plist) @@ -1636,7 +1642,7 @@ def _HasIOSTarget(targets): def _AddIOSDeviceConfigurations(targets): """Clone all targets and append -iphoneos to the name. Configure these targets to build for iOS devices and use correct architectures for those builds.""" - for target_dict in targets.itervalues(): + for target_dict in targets.values(): toolset = target_dict['toolset'] configs = target_dict['configurations'] for config_name, config_dict in dict(configs).items(): diff --git a/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py b/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py index 5acd82e004237..d70eddc90a57d 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py @@ -85,7 +85,7 @@ def _TargetFromSpec(old_spec, params): "%s/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" % ninja_toplevel if 'configurations' in old_spec: - for config in old_spec['configurations'].iterkeys(): + for config in old_spec['configurations']: old_xcode_settings = \ old_spec['configurations'][config].get('xcode_settings', {}) if 'IPHONEOS_DEPLOYMENT_TARGET' in old_xcode_settings: diff --git a/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py b/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py index b0385468c586a..93ffca7c90156 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py @@ -220,7 +220,7 @@ class XCObject(object): an empty string ("", in the case of property_type str) or list ([], in the case of is_list True) from being set for the property. - default: Optional. If is_requried is True, default may be set + default: Optional. If is_required is True, default may be set to provide a default value for objects that do not supply their own value. If is_required is True and default is not provided, users of the class must supply their own diff --git a/node_modules/node-gyp/gyp/tools/pretty_gyp.py b/node_modules/node-gyp/gyp/tools/pretty_gyp.py index d01c692edcf8d..633048a59ad28 100755 --- a/node_modules/node-gyp/gyp/tools/pretty_gyp.py +++ b/node_modules/node-gyp/gyp/tools/pretty_gyp.py @@ -18,7 +18,7 @@ # Regex to remove quoted strings when we're counting braces. # It takes into account quoted quotes, and makes sure that the quotes match. # NOTE: It does not handle quotes that span more than one line, or -# cases where an escaped quote is preceeded by an escaped backslash. +# cases where an escaped quote is preceded by an escaped backslash. QUOTE_RE_STR = r'(?P[\'"])(.*?)(? {}, error: () => {} } +delete TestPythonFinder.prototype.env.NODE_GYP_FORCE_PYTHON test('find python - python', function (t) { t.plan(6) diff --git a/package-lock.json b/package-lock.json index 2ed835d8774e7..b7a88137872ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3695,9 +3695,9 @@ } }, "node-gyp": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.3.tgz", - "integrity": "sha512-z/JdtkFGUm0QaQUusvloyYuGDub3nUbOo5de1Fz57cM++osBTvQatBUSTlF1k/w8vFHPxxXW6zxGvkxXSpaBkQ==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.4.tgz", + "integrity": "sha512-PMYap4ekQckQDZ2lxoORUF/nX13haU1JdCAlmLgvrykLyN0LFkhfwPbWhYjTxwTruCWbTkeOxFo043kjhmKHZA==", "requires": { "env-paths": "^1.0.0", "glob": "^7.0.3", @@ -3708,7 +3708,7 @@ "request": "^2.87.0", "rimraf": "2", "semver": "~5.3.0", - "tar": "^4.4.8", + "tar": "^4.4.12", "which": "1" }, "dependencies": { diff --git a/package.json b/package.json index 8728bdaebe38e..0fc2d7a101cbb 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "mississippi": "^3.0.0", "mkdirp": "~0.5.1", "move-concurrently": "^1.0.1", - "node-gyp": "^5.0.3", + "node-gyp": "^5.0.4", "nopt": "~4.0.1", "normalize-package-data": "^2.5.0", "npm-audit-report": "^1.3.2", From bbc92fb8f3478ff67071ebaff551f01c1ea42ced Mon Sep 17 00:00:00 2001 From: Ben Blank Date: Fri, 27 Sep 2019 11:04:44 -0700 Subject: [PATCH 09/27] Fix figgyPudding error in `npm token` It seems that a couple of lines were missed when token.js was [changed to use figgyPudding][1] which [causes an error][2] when trying to run that command in certain circumstances. This patch fixes that error. [1]: https://github.com/npm/cli/commit/4cf850d2be118abce72b3cf533f13512e9844ad1#diff-398ed3b014436a5204583323ea29320b [2]: https://npm.community/t/npm-token-err-figgypudding-options-cannot-be-modified-use-concat-instead/10288 PR-URL: https://github.com/npm/cli/pull/259 Credit: @benblank Close: #259 Reviewed-by: @isaacs --- lib/token.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/token.js b/lib/token.js index 9b1fbef9cecf4..96a05e45664f4 100644 --- a/lib/token.js +++ b/lib/token.js @@ -118,7 +118,6 @@ function config () { }) } else { conf = conf.concat({ auth: {} }) - conf.auth = {} } if (conf.otp) conf.auth.otp = conf.otp return conf From ed993a29ccf923425317c433844d55dbea2f23ee Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 10 Sep 2019 19:28:01 -0700 Subject: [PATCH 10/27] Add CI environment variables to user-agent The `npm-in-ci` header has been sent for some time now by make-fetch-happen, but User-Agent is more reliably logged and respected by proxies and CDNs, so that's a better place to put this. PR-URL: https://github.com/npm/cli/pull/249 Credit: @isaacs Close: #249 Reviewed-by: @isaacs --- lib/config/defaults.js | 3 ++- lib/npm.js | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/config/defaults.js b/lib/config/defaults.js index f563357d4cba3..1ee307580fc14 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -201,7 +201,8 @@ Object.defineProperty(exports, 'defaults', {get: function () { 'user-agent': 'npm/{npm-version} ' + 'node/{node-version} ' + '{platform} ' + - '{arch}', + '{arch} ' + + '{ci}', 'read-only': false, 'rebuild-bundle': true, registry: 'https://registry.npmjs.org/', diff --git a/lib/npm.js b/lib/npm.js index 2ee9a991264c7..35850078f834d 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -281,7 +281,27 @@ ua = ua.replace(/\{npm-version\}/gi, npm.version) ua = ua.replace(/\{platform\}/gi, process.platform) ua = ua.replace(/\{arch\}/gi, process.arch) - config.set('user-agent', ua) + + // continuous integration platforms + const ci = process.env.GERRIT_PROJECT ? 'ci/gerrit' + : process.env.GITLAB_CI ? 'ci/gitlab' + : process.env.CIRCLECI ? 'ci/circle-ci' + : process.env.SEMAPHORE ? 'ci/semaphore' + : process.env.DRONE ? 'ci/drone' + : process.env.GITHUB_ACTION ? 'ci/github-actions' + : process.env.TDDIUM ? 'ci/tddium' + : process.env.JENKINS_URL ? 'ci/jenkins' + : process.env['bamboo.buildKey'] ? 'ci/bamboo' + : process.env.GO_PIPELINE_NAME ? 'ci/gocd' + // codeship and a few others + : process.env.CI_NAME ? `ci/${process.env.CI_NAME}` + // test travis last, since many of these mimic it + : process.env.TRAVIS ? 'ci/travis-ci' + : process.env.CI === 'true' || process.env.CI === '1' ? 'ci/custom' + : '' + ua = ua.replace(/\{ci\}/gi, ci) + + config.set('user-agent', ua.trim()) if (config.get('metrics-registry') == null) { config.set('metrics-registry', config.get('registry')) From 248e3b3e21c86dc80f2d75da51d5d3ba491701e8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 6 Sep 2019 23:51:55 +0200 Subject: [PATCH 11/27] The sudo: tag is deprecated on Travis CI PR-URL: https://github.com/npm/cli/pull/247 Credit: @cclauss Close: #247 Reviewed-by: @isaacs --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1d2e3120c4e84..151be8440adb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -sudo: true # need to declare the language as well as the matrix below language: node_js From 5aba50ad0889d468ecfa9d6d0446a89f70db73d5 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Thu, 26 Sep 2019 00:25:40 -0400 Subject: [PATCH 12/27] fix: warn message on engine mismatch - Fixed setting engine check warnings to each package - Added proper catching of package warnings during validation phase - Added tap test that validates print of engine warn msgs Fix: https://npm.community/t/engines-and-engines-strict-ignored/4792 PR-URL: https://github.com/npm/cli/pull/257 Credit: @ruyadorno Close: #257 Reviewed-by: @isaacs --- lib/install/validate-args.js | 12 ++++--- lib/install/validate-tree.js | 11 +++++- test/tap/check-engine-reqs.js | 13 ++++++- test/tap/validate-tree-check-warnings.js | 44 ++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 test/tap/validate-tree-check-warnings.js diff --git a/lib/install/validate-args.js b/lib/install/validate-args.js index 65b660417a4ca..386cce3ca939c 100644 --- a/lib/install/validate-args.js +++ b/lib/install/validate-args.js @@ -31,10 +31,14 @@ function hasMinimumFields (pkg, cb) { } } -function getWarnings (pkg) { - while (pkg.parent) pkg = pkg.parent +function setWarnings (pkg, warn) { if (!pkg.warnings) pkg.warnings = [] - return pkg.warnings + if (pkg.warnings.every(i => ( + i.code !== warn.code || + i.required !== warn.required || + i.pkgid !== warn.pkgid))) { + pkg.warnings.push(warn) + } } var isInstallable = module.exports.isInstallable = function (pkg, next) { @@ -48,7 +52,7 @@ var isInstallable = module.exports.isInstallable = function (pkg, next) { var strict = npm.config.get('engine-strict') checkEngine(pkg, npm.version, nodeVersion, force, strict, iferr(next, thenWarnEngineIssues)) function thenWarnEngineIssues (warn) { - if (warn) getWarnings(pkg).push(warn) + if (warn) setWarnings(pkg, warn) checkPlatform(pkg, force, next) } } diff --git a/lib/install/validate-tree.js b/lib/install/validate-tree.js index 24a140171d45c..5ac979a46c403 100644 --- a/lib/install/validate-tree.js +++ b/lib/install/validate-tree.js @@ -22,7 +22,8 @@ module.exports = function (idealTree, log, next) { [asyncMap, modules, function (mod, done) { chain([ mod.parent && !mod.isLink && [checkGit, mod.realpath], - [checkErrors, mod, idealTree] + [checkErrors, mod, idealTree], + [checkWarnings, mod, idealTree] ], done) }], [thenValidateAllPeerDeps, idealTree], @@ -36,6 +37,14 @@ function checkErrors (mod, idealTree, next) { next() } +function checkWarnings (mod, idealTree, next) { + const warnings = mod.package.warnings + if (warnings && (mod.parent || path.resolve(npm.globalDir, '..'))) { + warnings.forEach(warn => idealTree.warnings.push(warn)) + } + next() +} + function thenValidateAllPeerDeps (idealTree, next) { validate('OF', arguments) validateAllPeerDeps(idealTree, function (tree, pkgname, version) { diff --git a/test/tap/check-engine-reqs.js b/test/tap/check-engine-reqs.js index 7cbbcd354f997..7ebb29484d828 100644 --- a/test/tap/check-engine-reqs.js +++ b/test/tap/check-engine-reqs.js @@ -27,7 +27,6 @@ test('setup', function (t) { var INSTALL_OPTS = ['--loglevel', 'silly'] var EXEC_OPTS = {cwd: installIn} - test('install bad engine', function (t) { common.npm(['install', '--engine-strict', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) { t.ifError(err, 'npm ran without issue') @@ -43,6 +42,18 @@ test('force install bad engine', function (t) { }) }) +test('warns on bad engine not strict', function (t) { + common.npm(['install', '--json', installFrom], EXEC_OPTS, function (err, code, stdout, stderr) { + t.ifError(err, 'npm ran without issue') + t.is(code, 0, 'result code') + var result = JSON.parse(stdout) + t.match(result.warnings[1], /Unsupported engine/, 'reason for optional failure in JSON') + t.match(result.warnings[1], /1.0.0-not-a-real-version/, 'should print mismatch version info') + t.match(result.warnings[1], /Not compatible with your version of node/, 'incompatibility message') + t.done() + }) +}) + test('cleanup', function (t) { cleanup() t.end() diff --git a/test/tap/validate-tree-check-warnings.js b/test/tap/validate-tree-check-warnings.js new file mode 100644 index 0000000000000..7b0bd45359d2c --- /dev/null +++ b/test/tap/validate-tree-check-warnings.js @@ -0,0 +1,44 @@ +'use strict' +var test = require('tap').test +var log = require('npmlog') +var npm = require('../../lib/npm.js') +var checkEngine = require('npm-install-checks').checkEngine + +var idealTree = { + package: { + name: 'a b c', + version: '3.what' + }, + children: [{ + name: 'faulty-engine', + version: '0.0.1', + children: [], + engines: { + node: '>=2.0.0' + }, + package: { + name: 'faulty-engine', + version: '0.0.1' + } + }], + warnings: [] +} + +test('setup', function (t) { + const faultyEnginePkg = idealTree.children[0] + checkEngine(faultyEnginePkg, '1.0.0', '1.0.0', false, false, (err, warn) => { + t.ifError(err, 'check engine ran without issue') + faultyEnginePkg.package.warnings = [warn] + npm.load({}, t.end) + }) +}) + +test('validate-tree should collect warnings from modules', function (t) { + log.disableProgress() + var validateTree = require('../../lib/install/validate-tree.js') + validateTree(idealTree, log.newGroup('validate'), function (er, a, b) { + t.equal(idealTree.warnings[0].code, 'ENOTSUP', 'should have the correct error') + t.match(idealTree.warnings[0].message, /Unsupported engine/, 'reason for optional failure in JSON') + t.end() + }) +}) From 5c380e5a33d760bb66a4285b032ae5f50af27199 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 30 Sep 2019 10:44:07 -0700 Subject: [PATCH 13/27] stringify-package@1.0.1 --- node_modules/stringify-package/CHANGELOG.md | 10 +++++ node_modules/stringify-package/index.js | 3 +- node_modules/stringify-package/package.json | 42 ++++++++++----------- package-lock.json | 6 +-- package.json | 2 +- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/node_modules/stringify-package/CHANGELOG.md b/node_modules/stringify-package/CHANGELOG.md index 974d393ac0e08..2de91768d2790 100644 --- a/node_modules/stringify-package/CHANGELOG.md +++ b/node_modules/stringify-package/CHANGELOG.md @@ -2,5 +2,15 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [1.0.1](https://github.com/npm/stringify-package/compare/v1.0.0...v1.0.1) (2019-09-30) + + +### Bug Fixes + +* strict comparison ([0c5675f](https://github.com/npm/stringify-package/commit/0c5675f)), closes [#2](https://github.com/npm/stringify-package/issues/2) + + + # 1.0.0 (2018-07-18) diff --git a/node_modules/stringify-package/index.js b/node_modules/stringify-package/index.js index 0cc9de0a36365..cd291f295a59c 100644 --- a/node_modules/stringify-package/index.js +++ b/node_modules/stringify-package/index.js @@ -7,7 +7,8 @@ const CRLF = '\r\n' const LF = '\n' function stringifyPackage (data, indent, newline) { - const json = JSON.stringify(data, null, indent || DEFAULT_INDENT) + indent = indent || (indent === 0 ? 0 : DEFAULT_INDENT) + const json = JSON.stringify(data, null, indent) if (newline === CRLF) { return json.replace(/\n/g, CRLF) + CRLF diff --git a/node_modules/stringify-package/package.json b/node_modules/stringify-package/package.json index 9d2a9d5f161e0..a3f011da5d8f0 100644 --- a/node_modules/stringify-package/package.json +++ b/node_modules/stringify-package/package.json @@ -1,28 +1,29 @@ { - "_from": "stringify-package@^1.0.0", - "_id": "stringify-package@1.0.0", + "_from": "stringify-package@1.0.1", + "_id": "stringify-package@1.0.1", "_inBundle": false, - "_integrity": "sha512-JIQqiWmLiEozOC0b0BtxZ/AOUtdUZHCBPgqIZ2kSJJqGwgb9neo44XdTHUC4HZSGqi03hOeB7W/E8rAlKnGe9g==", + "_integrity": "sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg==", "_location": "/stringify-package", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "stringify-package@^1.0.0", + "raw": "stringify-package@1.0.1", "name": "stringify-package", "escapedName": "stringify-package", - "rawSpec": "^1.0.0", + "rawSpec": "1.0.1", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.0.1" }, "_requiredBy": [ "#USER", - "/" + "/", + "/libnpm" ], - "_resolved": "https://registry.npmjs.org/stringify-package/-/stringify-package-1.0.0.tgz", - "_shasum": "e02828089333d7d45cd8c287c30aa9a13375081b", - "_spec": "stringify-package@^1.0.0", - "_where": "/Users/dpogue/Coding/npm_cli", + "_resolved": "https://registry.npmjs.org/stringify-package/-/stringify-package-1.0.1.tgz", + "_shasum": "e5aa3643e7f74d0f28628b72f3dad5cecfc3ba85", + "_spec": "stringify-package@1.0.1", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Kat Marchán", "email": "kzm@zkat.tech" @@ -34,11 +35,9 @@ "deprecated": false, "description": "stringifies npm-written json files", "devDependencies": { - "standard": "*", - "standard-version": "*", - "tap": "*", - "weallbehave": "*", - "weallcontribute": "*" + "standard": "11", + "standard-version": "4", + "tap": "12" }, "files": [ "index.js" @@ -58,13 +57,12 @@ "url": "git+https://github.com/npm/stringify-package.git" }, "scripts": { - "postrelease": "npm publish && git push --follow-tags", + "postpublish": "git push --follow-tags", + "postrelease": "npm publish", "prerelease": "npm t", "pretest": "standard", "release": "standard-version -s", - "test": "tap -J --coverage --100 test/*.js", - "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", - "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" + "test": "tap -J --coverage --100 test/*.js" }, - "version": "1.0.0" + "version": "1.0.1" } diff --git a/package-lock.json b/package-lock.json index b7a88137872ce..a1846d83d1853 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5532,9 +5532,9 @@ } }, "stringify-package": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stringify-package/-/stringify-package-1.0.0.tgz", - "integrity": "sha512-JIQqiWmLiEozOC0b0BtxZ/AOUtdUZHCBPgqIZ2kSJJqGwgb9neo44XdTHUC4HZSGqi03hOeB7W/E8rAlKnGe9g==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stringify-package/-/stringify-package-1.0.1.tgz", + "integrity": "sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg==" }, "strip-ansi": { "version": "3.0.1", diff --git a/package.json b/package.json index 0fc2d7a101cbb..c474276ed45d6 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "sorted-object": "~2.0.1", "sorted-union-stream": "~2.1.3", "ssri": "^6.0.1", - "stringify-package": "^1.0.0", + "stringify-package": "^1.0.1", "tar": "^4.4.12", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", From f6b0459a466a2c663dbd549cdc331e7732552dca Mon Sep 17 00:00:00 2001 From: Nikita Lebedev Date: Sat, 6 Apr 2019 04:06:33 +0500 Subject: [PATCH 14/27] Add option to save package-lock without formatting Adds a new config `--format-package-lock`, which defaults to true. If set to false, then the package lock will be written without any indentation or line breaks. PR-URL: https://github.com/npm/cli/pull/248 Credit: @bl00mber Close: #248 Reviewed-by: @isaacs Note: squashed and edited slightly for style. -- @isaacs --- doc/misc/npm-config.md | 7 ++ lib/config/defaults.js | 2 + lib/shrinkwrap.js | 8 ++- test/tap/format-package-lock.js | 116 ++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 test/tap/format-package-lock.js diff --git a/doc/misc/npm-config.md b/doc/misc/npm-config.md index 88d30b62ca252..f1055a56edbc7 100644 --- a/doc/misc/npm-config.md +++ b/doc/misc/npm-config.md @@ -387,6 +387,13 @@ Makes various commands more forceful. * skips cache when requesting from the registry. * prevents checks against clobbering non-npm files. +### format-package-lock + +* Default: true +* Type: Boolean + +Format `package-lock.json` or `npm-shrinkwrap.json` as a human readable file. + ### fetch-retries * Default: 2 diff --git a/lib/config/defaults.js b/lib/config/defaults.js index 1ee307580fc14..57d373df1e10c 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -141,6 +141,7 @@ Object.defineProperty(exports, 'defaults', {get: function () { editor: osenv.editor(), 'engine-strict': false, force: false, + 'format-package-lock': true, 'fetch-retries': 2, 'fetch-retry-factor': 10, @@ -283,6 +284,7 @@ exports.types = { editor: String, 'engine-strict': Boolean, force: Boolean, + 'format-package-lock': Boolean, 'fetch-retries': Number, 'fetch-retry-factor': Number, 'fetch-retry-mintimeout': Number, diff --git a/lib/shrinkwrap.js b/lib/shrinkwrap.js index 0a3f53546ca87..5428e7255b81d 100644 --- a/lib/shrinkwrap.js +++ b/lib/shrinkwrap.js @@ -282,11 +282,15 @@ function checkPackageFile (dir, name) { return readFile( file, 'utf8' ).then((data) => { + const format = npm.config.get('format-package-lock') !== false + const indent = format ? detectIndent(data).indent : 0 + const newline = format ? detectNewline(data) : 0 + return { path: file, raw: data, - indent: detectIndent(data).indent, - newline: detectNewline(data) + indent, + newline } }).catch({code: 'ENOENT'}, () => {}) } diff --git a/test/tap/format-package-lock.js b/test/tap/format-package-lock.js new file mode 100644 index 0000000000000..ddf40915d9bd3 --- /dev/null +++ b/test/tap/format-package-lock.js @@ -0,0 +1,116 @@ +'use strict' +const fs = require('fs') +const path = require('path') +const test = require('tap').test +const mr = require('npm-registry-mock') +const Tacks = require('tacks') +const File = Tacks.File +const Dir = Tacks.Dir +const common = require('../common-tap.js') + +const basedir = common.pkg +const testdir = path.join(basedir, 'testdir') +const cachedir = common.cache +const globaldir = path.join(basedir, 'global') +const tmpdir = path.join(basedir, 'tmp') + +const pkgPath = path.join(testdir, 'package.json') +const pkgLockPath = path.join(testdir, 'package-lock.json') +const shrinkwrapPath = path.join(testdir, 'npm-shrinkwrap.json') +const CRLFreg = /\r\n|\r|\n/ + +const env = common.newEnv().extend({ + npm_config_cache: cachedir, + npm_config_tmp: tmpdir, + npm_config_prefix: globaldir, + npm_config_registry: common.registry, + npm_config_loglevel: 'warn', + npm_config_format_package_lock: false +}) + +var server +var fixture = new Tacks(Dir({ + cache: Dir(), + global: Dir(), + tmp: Dir(), + testdir: Dir({ + 'package.json': File({ + name: 'install-package-lock-only', + version: '1.0.0', + dependencies: { + mkdirp: '^0.3.4' + } + }) + }) +})) + +function setup () { + cleanup() + fixture.create(basedir) +} + +function cleanup () { + fixture.remove(basedir) +} + +test('setup', function (t) { + mr({port: common.port, throwOnUnmatched: true}, function (err, s) { + if (err) throw err + server = s + t.done() + }) +}) + +test('package-lock.json unformatted, package.json formatted when config has `format-package-lock: false`', function (t) { + setup() + common.npm(['install'], {cwd: testdir, env}).spread((code, stdout, stderr) => { + t.is(code, 0, 'ok') + t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created') + const pkgLockUtf8 = fs.readFileSync(pkgLockPath, 'utf-8') + t.equal(pkgLockUtf8.split(CRLFreg).length, 2, 'package-lock.json is unformatted') + const pkgUtf8 = fs.readFileSync(pkgPath, 'utf-8') + t.notEqual(pkgUtf8.split(CRLFreg).length, 2, 'package.json is formatted') + t.done() + }) +}) + +test('npm-shrinkwrap.json unformatted when config has `format-package-lock: false`', function (t) { + setup() + common.npm(['shrinkwrap'], {cwd: testdir, env}).spread((code, stdout, stderr) => { + t.is(code, 0, 'ok') + t.ok(fs.existsSync(shrinkwrapPath), 'ensure that npm-shrinkwrap.json was created') + const shrinkwrapUtf8 = fs.readFileSync(shrinkwrapPath, 'utf-8') + t.equal(shrinkwrapUtf8.split(CRLFreg).length, 2, 'npm-shrinkwrap.json is unformatted') + t.done() + }) +}) + +test('package-lock.json and package.json formatted when config has `format-package-lock: true`', function (t) { + setup() + common.npm(['install'], {cwd: testdir}).spread((code, stdout, stderr) => { + t.is(code, 0, 'ok') + t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created') + const pkgLockUtf8 = fs.readFileSync(pkgLockPath, 'utf-8') + t.notEqual(pkgLockUtf8.split(CRLFreg).length, 2, 'package-lock.json is formatted') + const pkgUtf8 = fs.readFileSync(pkgPath, 'utf-8') + t.notEqual(pkgUtf8.split(CRLFreg).length, 2, 'package.json is formatted') + t.done() + }) +}) + +test('npm-shrinkwrap.json formatted when config has `format-package-lock: true`', function (t) { + setup() + common.npm(['shrinkwrap'], {cwd: testdir}).spread((code, stdout, stderr) => { + t.is(code, 0, 'ok') + t.ok(fs.existsSync(shrinkwrapPath), 'ensure that npm-shrinkwrap.json was created') + const shrinkwrapUtf8 = fs.readFileSync(shrinkwrapPath, 'utf-8') + t.notEqual(shrinkwrapUtf8.split(CRLFreg).length, 2, 'npm-shrinkwrap.json is unformatted') + t.done() + }) +}) + +test('cleanup', function (t) { + server.close() + cleanup() + t.done() +}) From 726fba74a922254221b15ae474a15cd9abafeadf Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 30 Sep 2019 10:52:02 -0700 Subject: [PATCH 15/27] docs: changelog for 6.12.0 --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c710a662cb44..2b6911d7f0d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 6.12.0 (2019-10-01): -Now `npm ci` runs prepare scripts for git dependencies, and respects the `--no-optional` argument. +Now `npm ci` runs prepare scripts for git dependencies, and respects the +`--no-optional` argument. ### BUG FIXES @@ -8,6 +9,28 @@ Now `npm ci` runs prepare scripts for git dependencies, and respects the `--no-o [#252](https://github.com/npm/cli/pull/252) chore(ci): add dirPacker to options ([@claudiahdz](https://github.com/claudiahdz)) +* [`5aba50ad0`](https://github.com/npm/cli/commit/5aba50ad0889d468ecfa9d6d0446a89f70db73d5) + [#257](https://github.com/npm/cli/pull/257) + [npm.community#4792](https://npm.community/t/engines-and-engines-strict-ignored/4792) + warn message on engine mismatch + ([@ruyadorno](https://github.com/ruyadorno)) +* [`bbc92fb8f`](https://github.com/npm/cli/commit/bbc92fb8f3478ff67071ebaff551f01c1ea42ced) + [#259](https://github.com/npm/cli/pull/259) + [npm.community#10288](https://npm.community/t/npm-token-err-figgypudding-options-cannot-be-modified-use-concat-instead/10288) + Fix figgyPudding error in `npm token` + ([@benblank](https://github.com/benblank)) + +### FEATURES + +* [`ed993a29c`](https://github.com/npm/cli/commit/ed993a29ccf923425317c433844d55dbea2f23ee) + [#249](https://github.com/npm/cli/pull/249) + Add CI environment variables to user-agent + ([@isaacs](https://github.com/isaacs)) +* [`f6b0459a4`](https://github.com/npm/cli/commit/f6b0459a466a2c663dbd549cdc331e7732552dca) + [#248](https://github.com/npm/cli/pull/248) + Add option to save package-lock without formatting + Adds a new config `--format-package-lock`, which defaults to true. + ([@bl00mber](https://github.com/bl00mber)) ### DEPENDENCIES @@ -20,7 +43,14 @@ Now `npm ci` runs prepare scripts for git dependencies, and respects the `--no-o - respect no-optional argument ([@cruzdanilo](https://github.com/cruzdanilo)) * [`7e04f728c`](https://github.com/npm/cli/commit/7e04f728cc4cd4853a8fc99e2df0a12988897589) `tar@4.4.12` - +* [`5c380e5a3`](https://github.com/npm/cli/commit/5c380e5a33d760bb66a4285b032ae5f50af27199) + `stringify-package@1.0.1` + ([@isaacs](https://github.com/isaacs)) +* [`bee6d42c6`](https://github.com/npm/cli/commit/bee6d42c68733fb59d3698f5d80fb748901f2a60) + [#260](https://github.com/npm/cli/pull/260) + `node-gyp@5.0.4`: + ([@isaacs](https://github.com/isaacs)) + ## 6.11.3 (2019-09-03): From 0ff0ea47a8840dd7d952bde7f7983a5016cda8ea Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 30 Sep 2019 13:51:20 -0700 Subject: [PATCH 16/27] npm-install-checks@3.0.2 --- node_modules/npm-install-checks/index.js | 5 +- node_modules/npm-install-checks/package.json | 39 +++---- .../npm-install-checks/test/check-engine.js | 62 ----------- .../npm-install-checks/test/check-git.js | 37 ------- .../npm-install-checks/test/check-platform.js | 104 ------------------ package-lock.json | 6 +- package.json | 2 +- 7 files changed, 27 insertions(+), 228 deletions(-) delete mode 100644 node_modules/npm-install-checks/test/check-engine.js delete mode 100644 node_modules/npm-install-checks/test/check-git.js delete mode 100644 node_modules/npm-install-checks/test/check-platform.js diff --git a/node_modules/npm-install-checks/index.js b/node_modules/npm-install-checks/index.js index 9ea7b875e4234..a533c9d36063e 100644 --- a/node_modules/npm-install-checks/index.js +++ b/node_modules/npm-install-checks/index.js @@ -7,9 +7,10 @@ exports.checkEngine = checkEngine function checkEngine (target, npmVer, nodeVer, force, strict, cb) { var nodev = force ? null : nodeVer var eng = target.engines + var opt = { includePrerelease: true } if (!eng) return cb() - if (nodev && eng.node && !semver.satisfies(nodev, eng.node) || - eng.npm && !semver.satisfies(npmVer, eng.npm)) { + if (nodev && eng.node && !semver.satisfies(nodev, eng.node, opt) || + eng.npm && !semver.satisfies(npmVer, eng.npm, opt)) { var er = new Error(util.format('Unsupported engine for %s: wanted: %j (current: %j)', target._id, eng, {node: nodev, npm: npmVer})) er.code = 'ENOTSUP' diff --git a/node_modules/npm-install-checks/package.json b/node_modules/npm-install-checks/package.json index e186c6a5ad960..dc409c761cc54 100644 --- a/node_modules/npm-install-checks/package.json +++ b/node_modules/npm-install-checks/package.json @@ -1,32 +1,28 @@ { - "_args": [ - [ - "npm-install-checks@3.0.0", - "/Users/rebecca/code/npm" - ] - ], - "_from": "npm-install-checks@3.0.0", - "_id": "npm-install-checks@3.0.0", + "_from": "npm-install-checks@3.0.2", + "_id": "npm-install-checks@3.0.2", "_inBundle": false, - "_integrity": "sha1-1K7N/VGlPjcjt7L5Oy7ijjB7wNc=", + "_integrity": "sha512-E4kzkyZDIWoin6uT5howP8VDvkM+E8IQDcHAycaAxMbwkqhIg5eEYALnXOl3Hq9MrkdQB/2/g1xwBINXdKSRkg==", "_location": "/npm-install-checks", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "npm-install-checks@3.0.0", + "raw": "npm-install-checks@3.0.2", "name": "npm-install-checks", "escapedName": "npm-install-checks", - "rawSpec": "3.0.0", + "rawSpec": "3.0.2", "saveSpec": null, - "fetchSpec": "3.0.0" + "fetchSpec": "3.0.2" }, "_requiredBy": [ + "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-3.0.0.tgz", - "_spec": "3.0.0", - "_where": "/Users/rebecca/code/npm", + "_resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-3.0.2.tgz", + "_shasum": "ab2e32ad27baa46720706908e5b14c1852de44d9", + "_spec": "npm-install-checks@3.0.2", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Robert Kowalski", "email": "rok@kowalski.gd" @@ -34,16 +30,21 @@ "bugs": { "url": "https://github.com/npm/npm-install-checks/issues" }, + "bundleDependencies": false, "dependencies": { "semver": "^2.3.0 || 3.x || 4 || 5" }, + "deprecated": false, "description": "checks that npm runs during the installation of a module", "devDependencies": { - "mkdirp": "~0.3.5", - "rimraf": "~2.2.5", + "mkdirp": "^0.5.1", + "rimraf": "^2.6.3", "standard": "^5.4.1", - "tap": "^5.0.1" + "tap": "^12.4.0" }, + "files": [ + "index.js" + ], "homepage": "https://github.com/npm/npm-install-checks", "keywords": [ "npm,", @@ -59,5 +60,5 @@ "scripts": { "test": "standard && tap --coverage test/*.js" }, - "version": "3.0.0" + "version": "3.0.2" } diff --git a/node_modules/npm-install-checks/test/check-engine.js b/node_modules/npm-install-checks/test/check-engine.js deleted file mode 100644 index a8fa0390a1347..0000000000000 --- a/node_modules/npm-install-checks/test/check-engine.js +++ /dev/null @@ -1,62 +0,0 @@ -var test = require('tap').test -var c = require('../index.js').checkEngine - -test('no engine defined', function (t) { - c({ engines: {} }, '1.1.2', '0.2.1', false, true, function (err) { - t.notOk(err, 'no error present') - t.end() - }) -}) - -test('node version too old', function (t) { - var target = { engines: { node: '0.10.24' } } - c(target, '1.1.2', '0.10.18', false, true, function (err) { - t.ok(err, 'returns an error') - t.equals(err.required.node, '0.10.24') - t.end() - }) -}) - -test('npm version too old', function (t) { - var target = { engines: { npm: '^1.4.6' } } - c(target, '1.3.2', '0.2.1', false, true, function (err) { - t.ok(err, 'returns an error') - t.equals(err.required.npm, '^1.4.6') - t.end() - }) -}) - -test('strict=false w/engineStrict json does not return an error', function (t) { - var target = { engines: { npm: '1.3.6' }, engineStrict: true } - c(target, '1.4.2', '0.2.1', false, false, function (err, warn) { - t.notOk(err, 'returns no error') - t.ok(warn, 'returns warning object') - t.equals(warn.required.npm, '1.3.6') - t.end() - }) -}) - -test('force node version too old', function (t) { - var target = { _id: 'test@1.0.0', engines: { node: '0.1.0' } } - c(target, '1.3.2', '0.2.1', true, true, function (err, warn) { - t.is(err, undefined, 'returns no error') - t.notOk(warn, 'returns no warning') - t.end() - }) -}) - -test('force npm version too old', function (t) { - var target = { _id: 'test@1.0.0', engines: { npm: '^1.4.6' } } - c(target, '1.3.2', '0.2.1', true, true, function (err, warn) { - t.ok(err, "can't force an npm version mismatch") - t.end() - }) -}) - -test('no engine', function (t) { - c({}, '1.3.2', '0.2.1', false, true, function (err, warn) { - t.notOk(err, 'returns no error') - t.notOk(warn, 'returns no warning') - t.end() - }) -}) diff --git a/node_modules/npm-install-checks/test/check-git.js b/node_modules/npm-install-checks/test/check-git.js deleted file mode 100644 index 0fadd0631b73d..0000000000000 --- a/node_modules/npm-install-checks/test/check-git.js +++ /dev/null @@ -1,37 +0,0 @@ -var test = require('tap').test -var c = require('../index.js').checkGit -var rimraf = require('rimraf') -var mkdirp = require('mkdirp') -var path = require('path') -var gitFixturePath = path.resolve(__dirname, 'out') - -test('is .git repo', function (t) { - mkdirp(gitFixturePath + '/.git', function () { - c(gitFixturePath, function (err) { - t.ok(err, 'error present') - t.equal(err.code, 'EISGIT') - t.end() - }) - }) -}) - -test('is not a .git repo', function (t) { - c(__dirname, function (err) { - t.notOk(err, 'error not present') - t.end() - }) -}) - -test('non-thing', function (t) { - c('/path/to/no/where', function (err) { - t.notOk(err, 'non-existent path is not a .git repo') - t.end() - }) -}) - -test('cleanup', function (t) { - rimraf(gitFixturePath, function () { - t.pass('cleanup') - t.end() - }) -}) diff --git a/node_modules/npm-install-checks/test/check-platform.js b/node_modules/npm-install-checks/test/check-platform.js deleted file mode 100644 index 23dbfba4a9b79..0000000000000 --- a/node_modules/npm-install-checks/test/check-platform.js +++ /dev/null @@ -1,104 +0,0 @@ -var test = require('tap').test -var c = require('../index.js').checkPlatform - -test('target cpu wrong', function (t) { - var target = {} - target.cpu = 'enten-cpu' - target.os = 'any' - c(target, false, function (err) { - t.ok(err, 'error present') - t.equal(err.code, 'EBADPLATFORM') - t.end() - }) -}) - -test('os wrong', function (t) { - var target = {} - target.cpu = 'any' - target.os = 'enten-os' - c(target, false, function (err) { - t.ok(err, 'error present') - t.equal(err.code, 'EBADPLATFORM') - t.end() - }) -}) - -test('nothing wrong', function (t) { - var target = {} - target.cpu = 'any' - target.os = 'any' - c(target, false, function (err) { - t.notOk(err, 'no error present') - t.end() - }) -}) - -test('force', function (t) { - var target = {} - target.cpu = 'enten-cpu' - target.os = 'any' - c(target, true, function (err) { - t.notOk(err, 'no error present') - t.end() - }) -}) - -test('no opinions', function (t) { - var target = {} - c(target, false, function (err) { - t.notOk(err, 'no error present') - t.end() - }) -}) - -test('only target cpu wrong', function (t) { - var target = {} - target.cpu = 'enten-cpu' - c(target, false, function (err) { - t.ok(err, 'error present') - t.equal(err.code, 'EBADPLATFORM') - t.end() - }) -}) - -test('only os wrong', function (t) { - var target = {} - target.os = 'enten-os' - c(target, false, function (err) { - t.ok(err, 'error present') - t.equal(err.code, 'EBADPLATFORM') - t.end() - }) -}) - -test('everything wrong w/arrays', function (t) { - var target = {} - target.cpu = ['enten-cpu'] - target.os = ['enten-os'] - c(target, false, function (err) { - t.ok(err, 'error present') - t.equal(err.code, 'EBADPLATFORM') - t.end() - }) -}) - -test('os wrong (negation)', function (t) { - var target = {} - target.cpu = 'any' - target.os = '!' + process.platform - c(target, false, function (err) { - t.ok(err, 'error present') - t.equal(err.code, 'EBADPLATFORM') - t.end() - }) -}) - -test('nothing wrong (negation)', function (t) { - var target = {} - target.cpu = '!enten-cpu' - target.os = '!enten-os' - c(target, false, function (err) { - t.notOk(err, 'no error present') - t.end() - }) -}) diff --git a/package-lock.json b/package-lock.json index a1846d83d1853..94d05d15c31ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3777,9 +3777,9 @@ "integrity": "sha1-3tMGxbC/yHCp6fr4I7xfKD4FrhE=" }, "npm-install-checks": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-3.0.0.tgz", - "integrity": "sha1-1K7N/VGlPjcjt7L5Oy7ijjB7wNc=", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-3.0.2.tgz", + "integrity": "sha512-E4kzkyZDIWoin6uT5howP8VDvkM+E8IQDcHAycaAxMbwkqhIg5eEYALnXOl3Hq9MrkdQB/2/g1xwBINXdKSRkg==", "requires": { "semver": "^2.3.0 || 3.x || 4 || 5" } diff --git a/package.json b/package.json index c474276ed45d6..e45da2e2f4526 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "normalize-package-data": "^2.5.0", "npm-audit-report": "^1.3.2", "npm-cache-filename": "~1.0.2", - "npm-install-checks": "~3.0.0", + "npm-install-checks": "^3.0.2", "npm-lifecycle": "^3.1.4", "npm-package-arg": "^6.1.1", "npm-packlist": "^1.4.4", From 8d129b8d83ab3e28179f07a559075e09cd39f5f8 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 30 Sep 2019 13:52:41 -0700 Subject: [PATCH 17/27] docs: changelog update for 6.12.0 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b6911d7f0d5b..f29fb583f5e44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,9 @@ Now `npm ci` runs prepare scripts for git dependencies, and respects the [#260](https://github.com/npm/cli/pull/260) `node-gyp@5.0.4`: ([@isaacs](https://github.com/isaacs)) +* [`0ff0ea47a`](https://github.com/npm/cli/commit/0ff0ea47a8840dd7d952bde7f7983a5016cda8ea) + `npm-install-checks@3.0.2` + ([@isaacs](https://github.com/isaacs)) ## 6.11.3 (2019-09-03): From dcff367a742257b00a21ad870ef370e4ecbd2f5d Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 1 Oct 2019 09:50:33 -0700 Subject: [PATCH 18/27] docs: update release date for 6.12.0 Pushing back a week to fix some bugs that have been found. - Engine check warnings get written to package.json, resulting in weird behavior later. - GitLab URL parsing needs a bit more tweaks to handle urls like /user/repo/repository/ref/archive.tar.gz --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f29fb583f5e44..867221ecac2d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 6.12.0 (2019-10-01): +## 6.12.0 (2019-10-08): Now `npm ci` runs prepare scripts for git dependencies, and respects the `--no-optional` argument. From 44a2b036b34324ec85943908264b2e36de5a9435 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 30 Sep 2019 10:21:10 -0700 Subject: [PATCH 19/27] fix root-ownership race conditions in meta-test Currently all of our tests verify on teardown that there are no root-owned files in the cache. However, owing to some race conditions and slippery stream event deferral behavior that won't be fixed until v7, occasionally cacache's chown doesn't get processed until _after_ the promise resolves and the test ends. As a result, sometimes this check occurs before the chown has happened, resulting in flaky hard-to-reproduce failures. The somewhat-kludgey solution here is to move the ownership check from t.teardown to process.on('exit'). In npm v7, we should move it back to t.teardown, because we should never have a test that resolves in such a way as to leave the cache in an invalid state. PR-URL: https://github.com/npm/cli/pull/262 Credit: @isaacs Close: #262 Reviewed-by: @isaacs --- test/common-tap.js | 44 ++++++++++--------- .../meta-test-flaky-root-ownership-test.js | 20 +++++++++ 2 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 test/tap/meta-test-flaky-root-ownership-test.js diff --git a/test/common-tap.js b/test/common-tap.js index 83a61f4bdbefa..d8dc8a10d870e 100644 --- a/test/common-tap.js +++ b/test/common-tap.js @@ -60,29 +60,31 @@ const find = require('which').sync('find') require('tap').teardown(() => { // work around windows folder locking process.chdir(returnCwd) - try { - if (isSudo) { - // running tests as sudo. ensure we didn't leave any root-owned - // files in the cache by mistake. - const args = [ commonCache, '-uid', '0' ] - const found = spawnSync(find, args) - const output = found && found.stdout && found.stdout.toString() - if (output.length) { - const er = new Error('Root-owned files left in cache!') - er.testName = main - er.files = output.trim().split('\n') - throw er + process.on('exit', () => { + try { + if (isSudo) { + // running tests as sudo. ensure we didn't leave any root-owned + // files in the cache by mistake. + const args = [ commonCache, '-uid', '0' ] + const found = spawnSync(find, args) + const output = found && found.stdout && found.stdout.toString() + if (output.length) { + const er = new Error('Root-owned files left in cache!') + er.testName = main + er.files = output.trim().split('\n') + throw er + } + } + if (!process.env.NO_TEST_CLEANUP) { + rimraf.sync(exports.pkg) + rimraf.sync(commonCache) + } + } catch (e) { + if (process.platform !== 'win32') { + throw e } } - if (!process.env.NO_TEST_CLEANUP) { - rimraf.sync(exports.pkg) - rimraf.sync(commonCache) - } - } catch (e) { - if (process.platform !== 'win32') { - throw e - } - } + }) }) var port = exports.port = 15443 + testId diff --git a/test/tap/meta-test-flaky-root-ownership-test.js b/test/tap/meta-test-flaky-root-ownership-test.js new file mode 100644 index 0000000000000..24dd9e3d95dda --- /dev/null +++ b/test/tap/meta-test-flaky-root-ownership-test.js @@ -0,0 +1,20 @@ +const t = require('tap') +if (!process.getuid || process.getuid() !== 0 || !process.env.SUDO_UID || !process.env.SUDO_GID) { + t.pass('this test only runs in sudo mode') + t.end() + process.exit(0) +} + +const common = require('../common-tap.js') +const fs = require('fs') +const mkdirp = require('mkdirp') +mkdirp.sync(common.cache + '/root/owned') +fs.writeFileSync(common.cache + '/root/owned/file.txt', 'should be chowned') +const chown = require('chownr') + +// this will fire after t.teardown() but before process.on('exit') +setTimeout(() => { + chown.sync(common.cache, +process.env.SUDO_UID, +process.env.SUDO_GID) +}, 100) + +t.pass('this is fine') From 62f2ca692ac0c0467ef4cf74f91777a5175258c4 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 7 Oct 2019 16:25:32 -0700 Subject: [PATCH 20/27] node-gyp@5.0.5 --- node_modules/node-gyp/.travis.yml | 20 +++- node_modules/node-gyp/CHANGELOG.md | 13 +++ node_modules/node-gyp/README.md | 38 +++++-- node_modules/node-gyp/bin/node-gyp.js | 2 +- .../node-gyp/gyp/pylib/gyp/MSVSNew.py | 3 + .../node-gyp/gyp/pylib/gyp/xcode_emulation.py | 2 +- node_modules/node-gyp/lib/configure.js | 22 ++-- node_modules/node-gyp/lib/find-python.js | 22 ++-- .../node-gyp/lib/find-visualstudio.js | 19 +++- node_modules/node-gyp/lib/install.js | 16 ++- node_modules/node-gyp/lib/node-gyp.js | 8 +- node_modules/node-gyp/lib/process-release.js | 13 ++- node_modules/node-gyp/package.json | 22 ++-- .../test/fixtures/VS_2017_Express.txt | 1 + .../node-gyp/test/process-exec-sync.js | 2 +- node_modules/node-gyp/test/test-addon.js | 16 +-- .../node-gyp/test/test-configure-python.js | 18 +-- .../test/test-find-accessible-sync.js | 16 +-- .../node-gyp/test/test-find-node-directory.js | 8 +- .../node-gyp/test/test-find-visualstudio.js | 36 +++++- .../node-gyp/test/test-process-release.js | 104 +++++++++++++++--- package-lock.json | 6 +- package.json | 2 +- 23 files changed, 289 insertions(+), 120 deletions(-) create mode 100644 node_modules/node-gyp/test/fixtures/VS_2017_Express.txt diff --git a/node_modules/node-gyp/.travis.yml b/node_modules/node-gyp/.travis.yml index f27f024f2d9a2..cf0ea43fff2d6 100644 --- a/node_modules/node-gyp/.travis.yml +++ b/node_modules/node-gyp/.travis.yml @@ -31,25 +31,33 @@ matrix: - name: "Node.js 6 & Python 3.7 on Linux" python: 3.7 - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 + env: NODE_GYP_FORCE_PYTHON=python3 before_install: nvm install 6 - name: "Node.js 8 & Python 3.7 on Linux" python: 3.7 - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 + env: NODE_GYP_FORCE_PYTHON=python3 before_install: nvm install 8 - name: "Node.js 10 & Python 3.7 on Linux" python: 3.7 - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 + env: NODE_GYP_FORCE_PYTHON=python3 before_install: nvm install 10 + - name: "Node.js 12 & Python 3.5 on Linux" + python: 3.5 + env: NODE_GYP_FORCE_PYTHON=python3 + before_install: nvm install 12 + - name: "Node.js 12 & Python 3.6 on Linux" + python: 3.6 + env: NODE_GYP_FORCE_PYTHON=python3 + before_install: nvm install 12 - name: "Node.js 12 & Python 3.7 on Linux" python: 3.7 - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 + env: NODE_GYP_FORCE_PYTHON=python3 before_install: nvm install 12 - name: "Python 3.7 on macOS" os: osx #osx_image: xcode11 language: shell # 'language: python' is not yet supported on macOS - env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1 + env: NODE_GYP_FORCE_PYTHON=python3 before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew install npm - name: "Node.js 12 & Python 3.7 on Windows" os: windows @@ -58,7 +66,6 @@ matrix: env: >- PATH=/c/Python37:/c/Python37/Scripts:$PATH NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe - EXPERIMENTAL_NODE_GYP_PYTHON3=1 before_install: choco install python install: @@ -71,6 +78,7 @@ before_script: # exit-zero treats all errors as warnings. Two space indentation is OK. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --ignore=E111,E114,W503 --max-complexity=10 --max-line-length=127 --statistics - npm install + - npm list script: - node -e 'require("npmlog").level="verbose"; require("./lib/find-python")(null,()=>{})' - npm test diff --git a/node_modules/node-gyp/CHANGELOG.md b/node_modules/node-gyp/CHANGELOG.md index 3dbc5d9244eba..ecc51b360dd18 100644 --- a/node_modules/node-gyp/CHANGELOG.md +++ b/node_modules/node-gyp/CHANGELOG.md @@ -1,3 +1,16 @@ +v5.0.5 2019-10-04 +================= + +* [[`3891391746`](https://github.com/nodejs/node-gyp/commit/3891391746)] - **doc**: reconcile README with Python 3 compat changes (Rod Vagg) [#1911](https://github.com/nodejs/node-gyp/pull/1911) +* [[`07f81f1920`](https://github.com/nodejs/node-gyp/commit/07f81f1920)] - **lib**: accept Python 3 after Python 2 (Sam Roberts) [#1910](https://github.com/nodejs/node-gyp/pull/1910) +* [[`04ce59f4a2`](https://github.com/nodejs/node-gyp/commit/04ce59f4a2)] - **doc**: clarify Python configuration, etc (Sam Roberts) [#1908](https://github.com/nodejs/node-gyp/pull/1908) +* [[`01c46ee3df`](https://github.com/nodejs/node-gyp/commit/01c46ee3df)] - **gyp**: add \_\_lt\_\_ to MSVSSolutionEntry (João Reis) [#1904](https://github.com/nodejs/node-gyp/pull/1904) +* [[`735d961b99`](https://github.com/nodejs/node-gyp/commit/735d961b99)] - **win**: support VS 2017 Desktop Express (João Reis) [#1902](https://github.com/nodejs/node-gyp/pull/1902) +* [[`3834156a92`](https://github.com/nodejs/node-gyp/commit/3834156a92)] - **test**: add Python 3.5 and 3.6 tests on Linux (cclauss) [#1909](https://github.com/nodejs/node-gyp/pull/1909) +* [[`1196e990d8`](https://github.com/nodejs/node-gyp/commit/1196e990d8)] - **src**: update to standard@14 (Rod Vagg) [#1899](https://github.com/nodejs/node-gyp/pull/1899) +* [[`53ee7dfe89`](https://github.com/nodejs/node-gyp/commit/53ee7dfe89)] - **gyp**: fix undefined name: cflags --\> ldflags (Christian Clauss) [#1901](https://github.com/nodejs/node-gyp/pull/1901) +* [[`5871dcf6c9`](https://github.com/nodejs/node-gyp/commit/5871dcf6c9)] - **src,win**: add support for fetching arm64 node.lib (Richard Townsend) [#1875](https://github.com/nodejs/node-gyp/pull/1875) + v5.0.4 2019-09-27 ================= diff --git a/node_modules/node-gyp/README.md b/node_modules/node-gyp/README.md index 0c76ffc09b4c0..d3930a253d4d1 100644 --- a/node_modules/node-gyp/README.md +++ b/node_modules/node-gyp/README.md @@ -1,9 +1,12 @@ # `node-gyp` - Node.js native addon build tool -`node-gyp` is a cross-platform command-line tool written in Node.js for compiling -native addon modules for Node.js. It bundles the [gyp](https://gyp.gsrc.io) -project used by the Chromium team and takes away the pain of dealing with the -various differences in build platforms. +`node-gyp` is a cross-platform command-line tool written in Node.js for +compiling native addon modules for Node.js. It contains a fork of the +[gyp](https://gyp.gsrc.io) project that was previously used by the Chromium +team and takes away the pain of dealing with the various differences in build +platforms. + +Note that `node-gyp` is _not_ used to build Node.js itself. Multiple target versions of Node.js are supported (i.e. `0.8`, ..., `4`, `5`, `6`, etc.), regardless of what version of Node.js is actually installed on your system @@ -25,20 +28,26 @@ $ npm install -g node-gyp You will also need to install: +NOTE: node-gyp is compatible with Python v2.7, v3.5, v3.6, or v3.7. If the +Python to use is not explicitly configured (see "Configuring Python Dependency" +below) it will attempt to find a compatible Python executable. + ### On Unix - * `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) + * Python v2.7, v3.5, v3.6, or v3.7 * `make` * A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org) ### On macOS - * `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) (already installed on macOS) + * Python v2.7, v3.5, v3.6, or v3.7 * [Xcode](https://developer.apple.com/xcode/download/) * You also need to install the `XCode Command Line Tools` by running `xcode-select --install`. Alternatively, if you already have the full Xcode installed, you can find them under the menu `Xcode -> Open Developer Tool -> More Developer Tools...`. This step will install `clang`, `clang++`, and `make`. ### On Windows +Install the current version of Python from the [Microsoft Store package](https://docs.python.org/3/using/windows.html#the-microsoft-store-package). + #### Option 1 Install all the required tools and configurations using Microsoft's [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) using `npm install --global --production windows-build-tools` from an elevated PowerShell or CMD.exe (run as Administrator). @@ -49,7 +58,6 @@ Install tools and configuration manually: * Install Visual C++ Build Environment: [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) (using "Visual C++ build tools" workload) or [Visual Studio 2017 Community](https://visualstudio.microsoft.com/pl/thank-you-downloading-visual-studio/?sku=Community) (using the "Desktop development with C++" workload) - * Install [Python 2.7](https://www.python.org/downloads/) (`v3.x.x` is not supported), and run `npm config set python python2.7` (or see below for further instructions on specifying the proper Python version and path.) * Launch cmd, `npm config set msvs_version 2017` If the above steps didn't work for you, please visit [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules) for additional tips. @@ -62,7 +70,7 @@ If you have multiple Python versions installed, you can identify which Python version `node-gyp` uses by setting the `--python` variable: ``` bash -$ node-gyp --python /path/to/executable/python2.7 +$ node-gyp --python /path/to/executable/python ``` If `node-gyp` is called by way of `npm`, *and* you have multiple versions of @@ -70,9 +78,17 @@ Python installed, then you can set `npm`'s 'python' config key to the appropriat value: ``` bash -$ npm config set python /path/to/executable/python2.7 +$ npm config set python /path/to/executable/python ``` +If the `PYTHON` environment variable is set to the path of a Python executable, +it will be used if it is a compatible Python. + +If the `NODE_GYP_FORCE_PYTHON` environment variable is set to the path of a +Python executable, it will be used instead of any of the other configured or +builtin Python search paths. If its not a compatible Python, no further +searching will be done. + ## How to Use To compile your native addon, first go to its root directory: @@ -119,7 +135,7 @@ JSON-like format. This file gets placed in the root of your package, alongside A barebones `gyp` file appropriate for building a Node.js addon could look like: -``` python +```python { "targets": [ { @@ -179,7 +195,7 @@ Some additional resources for addons and writing `gyp` files: | `--proxy=$url` | Set HTTP proxy for downloading header tarball | `--cafile=$cafile` | Override default CA chain (to download tarball) | `--nodedir=$path` | Set the path to the node source code -| `--python=$path` | Set path to the Python 2 binary +| `--python=$path` | Set path to the Python binary | `--msvs_version=$version` | Set Visual Studio version (Windows only) | `--solution=$solution` | Set Visual Studio Solution version (Windows only) diff --git a/node_modules/node-gyp/bin/node-gyp.js b/node_modules/node-gyp/bin/node-gyp.js index 13f2d399f737f..49b5721d02d89 100755 --- a/node_modules/node-gyp/bin/node-gyp.js +++ b/node_modules/node-gyp/bin/node-gyp.js @@ -131,7 +131,7 @@ function errorMessage () { function issueMessage () { errorMessage() - log.error('', [ 'This is a bug in `node-gyp`.', + log.error('', ['This is a bug in `node-gyp`.', 'Try to update node-gyp and file an Issue if it does not help:', ' ' ].join('\n')) diff --git a/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py b/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py index 9b64e2c1c8060..76c4b95c0c3e8 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py @@ -59,6 +59,9 @@ def __cmp__(self, other): # Sort by name then guid (so things are in order on vs2008). return cmp((self.name, self.get_guid()), (other.name, other.get_guid())) + def __lt__(self, other): + return self.__cmp__(other) < 0 + class MSVSFolder(MSVSSolutionEntry): """Folder in a Visual Studio project or solution.""" diff --git a/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py b/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py index 70f41e6bb4c17..74735c033a90b 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py @@ -846,7 +846,7 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None): if self._IsXCTest(): platform_root = self._XcodePlatformPath(configname) if platform_root: - cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') # noqa TODO @cclauss + ldflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension() if sdk_root and is_extension: diff --git a/node_modules/node-gyp/lib/configure.js b/node_modules/node-gyp/lib/configure.js index 20b955cabc0cb..564564eea4e6f 100644 --- a/node_modules/node-gyp/lib/configure.js +++ b/node_modules/node-gyp/lib/configure.js @@ -17,7 +17,7 @@ if (win) { function configure (gyp, argv, callback) { var python var buildDir = path.resolve('build') - var configNames = [ 'config.gypi', 'common.gypi' ] + var configNames = ['config.gypi', 'common.gypi'] var configs = [] var nodeDir var release = processRelease(argv, gyp, process.version, process.release) @@ -60,7 +60,7 @@ function configure (gyp, argv, callback) { // into devdir. Otherwise only install if they're not already there. gyp.opts.ensure = !gyp.opts.tarball - gyp.commands.install([ release.version ], function (err) { + gyp.commands.install([release.version], function (err) { if (err) { return callback(err) } @@ -132,7 +132,7 @@ function configure (gyp, argv, callback) { // set the target_arch variable variables.target_arch = gyp.opts.arch || process.arch || 'ia32' if (variables.target_arch === 'arm64') { - defaults['msvs_configuration_platform'] = 'ARM64' + defaults.msvs_configuration_platform = 'ARM64' } // set the node development directory @@ -142,22 +142,22 @@ function configure (gyp, argv, callback) { variables.standalone_static_library = gyp.opts.thin ? 0 : 1 if (win) { - process.env['GYP_MSVS_VERSION'] = Math.min(vsInfo.versionYear, 2015) - process.env['GYP_MSVS_OVERRIDE_PATH'] = vsInfo.path - defaults['msbuild_toolset'] = vsInfo.toolset + process.env.GYP_MSVS_VERSION = Math.min(vsInfo.versionYear, 2015) + process.env.GYP_MSVS_OVERRIDE_PATH = vsInfo.path + defaults.msbuild_toolset = vsInfo.toolset if (vsInfo.sdk) { - defaults['msvs_windows_target_platform_version'] = vsInfo.sdk + defaults.msvs_windows_target_platform_version = vsInfo.sdk } if (variables.target_arch === 'arm64') { if (vsInfo.versionMajor > 15 || (vsInfo.versionMajor === 15 && vsInfo.versionMajor >= 9)) { - defaults['msvs_enable_marmasm'] = 1 + defaults.msvs_enable_marmasm = 1 } else { log.warn('Compiling ARM64 assembly is only available in\n' + 'Visual Studio 2017 version 15.9 and above') } } - variables['msbuild_path'] = vsInfo.msBuild + variables.msbuild_path = vsInfo.msBuild } // loop through the rest of the opts and add the unknown ones as variables. @@ -190,7 +190,7 @@ function configure (gyp, argv, callback) { var json = JSON.stringify(config, boolsToString, 2) log.verbose('build/' + configFilename, 'writing out config file: %s', configPath) configs.push(configPath) - fs.writeFile(configPath, [ prefix, json, '' ].join('\n'), findConfigs) + fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs) } function findConfigs (err) { @@ -335,7 +335,7 @@ function configure (gyp, argv, callback) { argv.unshift(gypScript) // make sure python uses files that came with this particular node package - var pypath = [ path.join(__dirname, '..', 'gyp', 'pylib') ] + var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')] if (process.env.PYTHONPATH) { pypath.push(process.env.PYTHONPATH) } diff --git a/node_modules/node-gyp/lib/find-python.js b/node_modules/node-gyp/lib/find-python.js index 1a4390dbd2c9c..e79bc50d5a1d5 100644 --- a/node_modules/node-gyp/lib/find-python.js +++ b/node_modules/node-gyp/lib/find-python.js @@ -16,10 +16,9 @@ function PythonFinder (configPython, callback) { PythonFinder.prototype = { log: logWithPrefix(log, 'find Python'), - argsExecutable: [ '-c', 'import sys; print(sys.executable);' ], - argsVersion: [ '-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);' ], - semverRange: process.env.EXPERIMENTAL_NODE_GYP_PYTHON3 ? '2.7.x || >=3.5.0' - : '>=2.6.0 <3.0.0', + argsExecutable: ['-c', 'import sys; print(sys.executable);'], + argsVersion: ['-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);'], + semverRange: '^2.6.0 || >=3.5.0', // These can be overridden for testing: execFile: cp.execFile, @@ -46,7 +45,7 @@ PythonFinder.prototype = { function getChecks () { if (this.env.NODE_GYP_FORCE_PYTHON) { - return [ { + return [{ before: () => { this.addLog( 'checking Python explicitly set from NODE_GYP_FORCE_PYTHON') @@ -55,7 +54,7 @@ PythonFinder.prototype = { }, check: this.checkCommand, arg: this.env.NODE_GYP_FORCE_PYTHON - } ] + }] } var checks = [ @@ -97,6 +96,11 @@ PythonFinder.prototype = { before: () => { this.addLog('checking if "python2" can be used') }, check: this.checkCommand, arg: 'python2' + }, + { + before: () => { this.addLog('checking if "python3" can be used') }, + check: this.checkCommand, + arg: 'python3' } ] @@ -140,7 +144,7 @@ PythonFinder.prototype = { return this.fail() } - const args = [ runChecks.bind(this) ] + const args = [runChecks.bind(this)] if (check.arg) { args.unshift(check.arg) } @@ -192,7 +196,7 @@ PythonFinder.prototype = { checkPyLauncher: function checkPyLauncher (errorCallback) { this.log.verbose( `- executing "${this.pyLauncher}" to get Python 2 executable path`) - this.run(this.pyLauncher, [ '-2', ...this.argsExecutable ], false, + this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false, function (err, execPath) { // Possible outcomes: same as checkCommand if (err) { @@ -286,7 +290,7 @@ PythonFinder.prototype = { // X const info = [ '**********************************************************', - 'You need to install the latest version of Python 2.7.', + 'You need to install the latest version of Python.', 'Node-gyp should be able to find and use Python. If not,', 'you can try one of the following options:', `- Use the switch --python="${pathExample}"`, diff --git a/node_modules/node-gyp/lib/find-visualstudio.js b/node_modules/node-gyp/lib/find-visualstudio.js index b2c00e68355b7..c5d26f9a202ca 100644 --- a/node_modules/node-gyp/lib/find-visualstudio.js +++ b/node_modules/node-gyp/lib/find-visualstudio.js @@ -279,15 +279,22 @@ VisualStudioFinder.prototype = { // Helper - process toolset information getToolset: function getToolset (info, versionYear) { const pkg = 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' + const express = 'Microsoft.VisualStudio.WDExpress' + if (info.packages.indexOf(pkg) !== -1) { this.log.silly('- found VC.Tools.x86.x64') - if (versionYear === 2017) { - return 'v141' - } - if (versionYear === 2019) { - return 'v142' - } + } else if (info.packages.indexOf(express) !== -1) { + this.log.silly('- found Visual Studio Express (looking for toolset)') + } else { + return null + } + + if (versionYear === 2017) { + return 'v141' + } else if (versionYear === 2019) { + return 'v142' } + this.log.silly('- invalid versionYear:', versionYear) return null }, diff --git a/node_modules/node-gyp/lib/install.js b/node_modules/node-gyp/lib/install.js index 3730c0965f7f1..b870532880666 100644 --- a/node_modules/node-gyp/lib/install.js +++ b/node_modules/node-gyp/lib/install.js @@ -24,7 +24,7 @@ function install (fs, gyp, argv, callback) { if (err) { log.warn('install', 'got an error, rolling back install') // roll-back the install if anything went wrong - gyp.commands.remove([ release.versionDir ], function () { + gyp.commands.remove([release.versionDir], function () { callback(err) }) } else { @@ -298,7 +298,7 @@ function install (fs, gyp, argv, callback) { function downloadNodeLib (done) { log.verbose('on Windows; need to download `' + release.name + '.lib`...') - var archs = [ 'ia32', 'x64' ] + var archs = ['ia32', 'x64', 'arm64'] var async = archs.length archs.forEach(function (arch) { var dir = path.resolve(devDir, arch) @@ -323,7 +323,15 @@ function install (fs, gyp, argv, callback) { req.on('error', done) req.on('response', function (res) { - if (res.statusCode !== 200) { + if (res.statusCode === 404) { + if (arch === 'arm64') { + // Arm64 is a newer platform on Windows and not all node distributions provide it. + log.verbose(`${name} was not found in ${libUrl}`) + } else { + log.warn(`${name} was not found in ${libUrl}`) + } + return + } else if (res.statusCode !== 200) { done(new Error(res.statusCode + ' status code downloading ' + name)) return } @@ -392,7 +400,7 @@ function download (gyp, env, url) { uri: url, headers: { 'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')', - 'Connection': 'keep-alive' + Connection: 'keep-alive' } } diff --git a/node_modules/node-gyp/lib/node-gyp.js b/node_modules/node-gyp/lib/node-gyp.js index 91880f94339fa..9d24103900f70 100644 --- a/node_modules/node-gyp/lib/node-gyp.js +++ b/node_modules/node-gyp/lib/node-gyp.js @@ -18,8 +18,8 @@ const commands = [ 'remove' ] const aliases = { - 'ls': 'list', - 'rm': 'remove' + ls: 'list', + rm: 'remove' } // differentiate node-gyp's logs from npm's @@ -72,7 +72,7 @@ proto.configDefs = { loglevel: String, // everywhere python: String, // 'configure' 'dist-url': String, // 'install' - 'tarball': String, // 'install' + tarball: String, // 'install' jobs: String, // 'build' thin: String // 'configure' } @@ -167,7 +167,7 @@ proto.spawn = function spawn (command, args, opts) { opts = {} } if (!opts.silent && !opts.stdio) { - opts.stdio = [ 0, 1, 2 ] + opts.stdio = [0, 1, 2] } var cp = childProcess.spawn(command, args, opts) log.info('spawn', command) diff --git a/node_modules/node-gyp/lib/process-release.js b/node_modules/node-gyp/lib/process-release.js index 0acab061bd7b5..95b55e4426dee 100644 --- a/node_modules/node-gyp/lib/process-release.js +++ b/node_modules/node-gyp/lib/process-release.js @@ -1,3 +1,5 @@ +/* eslint-disable node/no-deprecated-api */ + 'use strict' const semver = require('semver') @@ -7,7 +9,7 @@ const log = require('npmlog') // versions where -headers.tar.gz started shipping const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42' -const bitsre = /\/win-(x86|x64)\// +const bitsre = /\/win-(x86|x64|arm64)\// const bitsreV3 = /\/win-(x86|ia32|x64)\// // io.js v3.x.x shipped with "ia32" but should // have been "x86" @@ -25,6 +27,7 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { var baseUrl var libUrl32 var libUrl64 + var libUrlArm64 var tarballUrl var canGetHeaders @@ -79,6 +82,7 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { baseUrl = url.resolve(defaultRelease.headersUrl, './') libUrl32 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x86', versionSemver.major) libUrl64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x64', versionSemver.major) + libUrlArm64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'arm64', versionSemver.major) tarballUrl = defaultRelease.headersUrl } else { // older versions without process.release are captured here and we have to make @@ -87,6 +91,7 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { baseUrl = distBaseUrl libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major) libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major) + libUrlArm64 = resolveLibUrl(name, baseUrl, 'arm64', versionSemver.major) // making the bold assumption that anything with a version number >3.0.0 will // have a *-headers.tar.gz file in its dist location, even some frankenstein @@ -110,6 +115,10 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { x64: { libUrl: libUrl64, libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path)) + }, + arm64: { + libUrl: libUrlArm64, + libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrlArm64).path)) } } } @@ -128,7 +137,7 @@ function resolveLibUrl (name, defaultUrl, arch, versionMajor) { return url.resolve(base, 'win-' + arch + '/' + name + '.lib') } // prior to io.js@1.0.0 32-bit node.lib lives in /, 64-bit lives in /x64/ - return url.resolve(base, (arch === 'x64' ? 'x64/' : '') + name + '.lib') + return url.resolve(base, (arch === 'x86' ? '' : arch + '/') + name + '.lib') } // else we have a proper url to a .lib, just make sure it's the right arch diff --git a/node_modules/node-gyp/package.json b/node_modules/node-gyp/package.json index ed4159a4369ba..a5a39e3f2ba92 100644 --- a/node_modules/node-gyp/package.json +++ b/node_modules/node-gyp/package.json @@ -1,8 +1,8 @@ { - "_from": "node-gyp@5.0.4", - "_id": "node-gyp@5.0.4", + "_from": "node-gyp@5.0.5", + "_id": "node-gyp@5.0.5", "_inBundle": false, - "_integrity": "sha512-PMYap4ekQckQDZ2lxoORUF/nX13haU1JdCAlmLgvrykLyN0LFkhfwPbWhYjTxwTruCWbTkeOxFo043kjhmKHZA==", + "_integrity": "sha512-WABl9s4/mqQdZneZHVWVG4TVr6QQJZUC6PAx47ITSk9lreZ1n+7Z9mMAIbA3vnO4J9W20P7LhCxtzfWsAD/KDw==", "_location": "/node-gyp", "_phantomChildren": { "abbrev": "1.1.1" @@ -10,21 +10,21 @@ "_requested": { "type": "version", "registry": true, - "raw": "node-gyp@5.0.4", + "raw": "node-gyp@5.0.5", "name": "node-gyp", "escapedName": "node-gyp", - "rawSpec": "5.0.4", + "rawSpec": "5.0.5", "saveSpec": null, - "fetchSpec": "5.0.4" + "fetchSpec": "5.0.5" }, "_requiredBy": [ "#USER", "/", "/npm-lifecycle" ], - "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.4.tgz", - "_shasum": "1de243f17b081a6e89f4330967900c816114f8fb", - "_spec": "node-gyp@5.0.4", + "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.5.tgz", + "_shasum": "f6cf1da246eb8c42b097d7cd4d6c3ce23a4163af", + "_spec": "node-gyp@5.0.5", "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Nathan Rajlich", @@ -57,7 +57,7 @@ "bindings": "~1.2.1", "nan": "^2.0.0", "require-inject": "~1.3.0", - "standard": "~12.0.1", + "standard": "~14.3.1", "tap": "~12.7.0" }, "engines": { @@ -86,5 +86,5 @@ "lint": "standard */*.js test/**/*.js", "test": "npm run lint && tap --timeout=120 test/test-*" }, - "version": "5.0.4" + "version": "5.0.5" } diff --git a/node_modules/node-gyp/test/fixtures/VS_2017_Express.txt b/node_modules/node-gyp/test/fixtures/VS_2017_Express.txt new file mode 100644 index 0000000000000..c4b3b5f2b0163 --- /dev/null +++ b/node_modules/node-gyp/test/fixtures/VS_2017_Express.txt @@ -0,0 +1 @@ +[{"path":"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\WDExpress","version":"15.9.28307.858","packages":["Microsoft.VisualStudio.Product.WDExpress","Microsoft.VisualStudio.Workload.WDExpress","Microsoft.VisualStudio.Component.Windows10SDK.17763","MLGen","Win10SDK_10.0.17763","Microsoft.VisualStudio.Component.Windows10SDK.14393","Win10SDK_10.0.14393.795","Microsoft.VisualStudio.VC.Items.Pro","Microsoft.VisualStudio.VC.Ide.Pro","Microsoft.VisualStudio.VC.Ide.Pro.Resources","Microsoft.VisualStudio.Component.VC.Tools.ARM64","Microsoft.VisualStudio.VC.MSBuild.Arm64","Microsoft.VisualCpp.CRT.Redist.ARM64.OneCore.Desktop","Microsoft.VisualCpp.CRT.Redist.ARM64","Microsoft.VisualCpp.CRT.ARM64.OneCore.Desktop","Microsoft.VisualCpp.CRT.ARM64.Store","Microsoft.VisualCpp.CRT.ARM64.Desktop","Microsoft.VisualCpp.Tools.Hostx86.Targetarm64","Microsoft.VisualCpp.VCTip.hostX86.targetARM64","Microsoft.VisualCpp.Tools.HostX86.TargetARM64.Resources","Microsoft.VisualStudio.Component.VC.Tools.ARM","Microsoft.VisualCpp.Tools.Hostx86.Targetarm","Microsoft.VisualCpp.VCTip.hostX86.targetARM","Microsoft.VisualCpp.Tools.HostX86.TargetARM.Resources","Microsoft.VisualCpp.CRT.x86.Store","Microsoft.VisualCpp.CRT.x86.OneCore.Desktop","Microsoft.VisualCpp.CRT.x64.Store","Microsoft.VisualCpp.CRT.x64.OneCore.Desktop","Microsoft.VisualCpp.CRT.Redist.arm.OneCore.Desktop","Microsoft.VisualCpp.CRT.arm.OneCore.Desktop","Microsoft.VisualCpp.CRT.arm.Store","Microsoft.VisualCpp.CRT.arm.Desktop","Microsoft.VisualStudio.VC.Templates.UnitTest","Microsoft.VisualStudio.TestTools.TestPlatform.V1.CPP","Microsoft.VisualStudio.VC.Templates.UnitTest.Resources","Microsoft.VisualStudio.VC.Templates.Desktop","Microsoft.VisualStudio.VC.Templates.Pro","Microsoft.VisualStudio.VC.Templates.Pro.Resources","Microsoft.VisualStudio.PackageGroup.VC.CoreIDE.Express","Microsoft.VisualStudio.PackageGroup.Debugger.Script","Microsoft.VisualStudio.JavaScript.LanguageService","Microsoft.VisualStudio.JavaScript.LanguageService.Resources","Microsoft.VisualStudio.Debugger.Script.Msi","Microsoft.VisualStudio.Debugger.Script","Microsoft.VisualStudio.Debugger.Script","Microsoft.VisualStudio.Debugger.Script.Resources","Microsoft.VisualStudio.Debugger.Script.Resources","Microsoft.VisualStudio.VC.MSBuild.X64","Microsoft.VS.VC.MSBuild.X64.Resources","Microsoft.VisualStudio.VC.MSBuild.ARM","Microsoft.VisualStudio.VC.MSBuild.X86","Microsoft.VisualStudio.VC.MSBuild.Base","Microsoft.VisualStudio.VC.MSBuild.Base.Resources","Microsoft.VisualStudio.VC.Ide.WinXPlus","Microsoft.VisualStudio.VC.Ide.Dskx","Microsoft.VisualStudio.VC.Ide.Dskx.Resources","Microsoft.VisualStudio.VC.Ide.Core","Microsoft.VisualStudio.VC.Ide.Core.Resources","Microsoft.VisualStudio.VC.Ide.Base","Microsoft.VisualStudio.VC.Ide.Base.Resources","Microsoft.VisualStudio.Component.VC.CLI.Support","Microsoft.VisualCpp.CLI.X86","Microsoft.VisualCpp.CLI.X64","Microsoft.VisualCpp.CLI.Source","Microsoft.VisualCpp.CLI.ARM64","Microsoft.VisualCpp.CLI.ARM","Microsoft.VisualStudio.VC.Templates.CLR","Microsoft.VisualStudio.VC.Ide.LanguageService","Microsoft.VisualStudio.VC.Ide.ResourceEditor","Microsoft.VisualStudio.VC.Ide.ResourceEditor.Resources","Microsoft.VisualStudio.VC.Ide.ProjectSystem","Microsoft.VisualStudio.VC.Ide.ProjectSystem.Resources","Microsoft.VisualStudio.VC.Ide.Core.VCProjectEngine","Microsoft.VisualStudio.VC.Ide.Core.VCProjectEngine.Resources","Microsoft.VisualStudio.VC.Ide.LanguageService.Resources","Microsoft.VisualStudio.VC.Templates.CLR.Resources","Microsoft.Component.VC.Runtime.OSSupport","Microsoft.Windows.UniversalCRT.Tools.Msi","Microsoft.Windows.UniversalCRT.Tools.Msi","Microsoft.Windows.UniversalCRT.ExtensionSDK.Msi","Microsoft.Windows.UniversalCRT.HeadersLibsSources.Msi","Microsoft.VisualStudio.PackageGroup.VC.Tools.x86","Microsoft.VisualCpp.Tools.HostX86.TargetX64","Microsoft.VisualCpp.VCTip.hostX86.targetX64","Microsoft.VisualCpp.Tools.Hostx86.Targetx64.Resources","Microsoft.VisualCpp.Tools.HostX86.TargetX86","Microsoft.VisualCpp.VCTip.hostX86.targetX86","Microsoft.VisualCpp.Tools.HostX86.TargetX86.Resources","Microsoft.VisualCpp.Tools.Core.Resources","Microsoft.VisualCpp.Tools.Core.x86","Microsoft.VisualCpp.Tools.Common.Utils","Microsoft.VisualCpp.Tools.Common.Utils.Resources","Microsoft.VisualCpp.DIA.SDK","Microsoft.VisualCpp.CRT.x86.Desktop","Microsoft.VisualCpp.CRT.x64.Desktop","Microsoft.VisualCpp.CRT.Source","Microsoft.VisualCpp.CRT.Redist.X86","Microsoft.VisualCpp.CRT.Redist.X64","Microsoft.VisualCpp.CRT.Redist.Resources","Microsoft.VisualCpp.RuntimeDebug.14","Microsoft.VisualCpp.RuntimeDebug.14","Microsoft.VisualCpp.CRT.Headers","Microsoft.Component.HelpViewer","Microsoft.HelpViewer","Microsoft.VisualStudio.Help.Configuration.Msi","Microsoft.VisualStudio.Component.SQL.DataSources","Microsoft.VisualStudio.Component.SQL.SSDT","Microsoft.VisualStudio.Component.SQL.CMDUtils","sqlcmdlnutils","Microsoft.VisualStudio.Component.Common.Azure.Tools","Microsoft.VisualStudio.Azure.CommonAzureTools","SSDT","Microsoft.VisualStudio.Component.SQL.ADAL","sql_adalsql","Microsoft.VisualStudio.Component.NuGet","Microsoft.CredentialProvider","Microsoft.VisualStudio.NuGet.Licenses","Microsoft.VisualStudio.Component.SQL.LocalDB.Runtime","Microsoft.VisualStudio.Component.SQL.NCLI","sqllocaldb","sqlncli","Microsoft.VisualStudio.Component.EntityFramework","Microsoft.VisualStudio.PackageGroup.DslRuntime","Microsoft.VisualStudio.Dsl.Core","Microsoft.VisualStudio.Dsl.GraphObject","Microsoft.VisualStudio.Dsl.Core.Resources","Microsoft.VisualStudio.EntityFrameworkTools","Microsoft.VisualStudio.EntityFrameworkTools.Msi","Microsoft.VisualStudio.Component.Roslyn.LanguageServices","Microsoft.VisualStudio.InteractiveWindow","Microsoft.DiaSymReader.Native","Microsoft.VisualStudio.Component.Static.Analysis.Tools","Microsoft.VisualCpp.Redist.14","Microsoft.VisualCpp.Redist.14","Microsoft.VisualStudio.StaticAnalysis","Microsoft.VisualStudio.StaticAnalysis.Resources","Microsoft.CodeAnalysis.VisualStudio.InteractiveComponents.Resources","Microsoft.CodeAnalysis.VisualStudio.InteractiveComponents","Microsoft.CodeAnalysis.VisualStudio.Setup.Interactive.Resources","Microsoft.Net.ComponentGroup.TargetingPacks.Common","Microsoft.Net.Component.4.6.TargetingPack","Microsoft.Net.4.6.TargetingPack","Microsoft.Net.Component.4.5.2.TargetingPack","Microsoft.Net.4.5.2.TargetingPack","Microsoft.Net.Component.4.5.1.TargetingPack","Microsoft.Net.4.5.1.TargetingPack","Microsoft.Net.Component.4.5.TargetingPack","Microsoft.Net.4.5.TargetingPack","Microsoft.Net.Component.4.TargetingPack","Microsoft.Net.4.TargetingPack","Microsoft.Net.ComponentGroup.DevelopmentPrerequisites","Microsoft.Net.Component.4.6.1.TargetingPack","Microsoft.Net.4.6.1.TargetingPack","Microsoft.Net.Cumulative.TargetingPack.Resources","Microsoft.Net.Component.4.6.1.SDK","Microsoft.Net.4.6.1.SDK","Microsoft.VisualStudio.Component.TextTemplating","Microsoft.VisualStudio.TextTemplating.MSBuild","Microsoft.VisualStudio.TextTemplating.Integration","Microsoft.VisualStudio.TextTemplating.Core","Microsoft.VisualStudio.TextTemplating.Integration.Resources","Microsoft.VisualStudio.Component.VisualStudioData","Microsoft.VisualStudio.Component.SQL.CLR","Microsoft.VisualStudio.ProTools","sqlsysclrtypes","sqlsysclrtypes","SQLCommon","Microsoft.VisualStudio.ProTools.Resources","Microsoft.VisualStudio.XamlDiagnostics","Microsoft.VisualStudio.XamlDiagnostics.Resources","Microsoft.VisualStudio.XamlDesigner","Microsoft.VisualStudio.XamlDesigner.Resources","Microsoft.VisualStudio.XamlDesigner.Executables","Microsoft.VisualStudio.XamlShared","Microsoft.VisualStudio.XamlShared.Resources","Microsoft.VisualStudio.PackageGroup.TestTools.Managed","Microsoft.VisualStudio.PackageGroup.IntelliTrace.Core","Microsoft.IntelliTrace.Core","Microsoft.IntelliTrace.Core.Targeted","Microsoft.IntelliTrace.ProfilerProxy.Msi.x64","Microsoft.IntelliTrace.ProfilerProxy.Msi","Microsoft.VisualStudio.NuGet.Core","Microsoft.VisualStudio.TestWindow.SourceBasedTestDiscovery","Microsoft.VisualStudio.TestWindow.Dotnet","Microsoft.VisualStudio.TestTools.TestGeneration","Microsoft.VisualStudio.PackageGroup.TestTools.CodeCoverage","Microsoft.VisualStudio.PackageGroup.TestTools.Enterprise","Microsoft.VisualStudio.PackageGroup.TestTools.MSTestV2.Managed","Microsoft.VisualStudio.TestTools.MSTestV2.WizardExtension.UnitTest","Microsoft.VisualStudio.PackageGroup.TestTools.Core","Microsoft.VisualStudio.PackageGroup.TestTools.TestPlatform.V2.CLI","Microsoft.VisualStudio.TestTools.TestPlatform.V2.CLI","Microsoft.VisualStudio.PackageGroup.TestTools.TestPlatform.V1.CLI","Microsoft.VisualStudio.TestTools.TestPlatform.V1.CLI","Microsoft.VisualStudio.TestTools.Pex.Common","Microsoft.VisualStudio.PackageGroup.TestTools.TestPlatform.Legacy","Microsoft.VisualStudio.PackageGroup.MinShell.Interop","Microsoft.VisualStudio.TestTools.TP.Legacy.Tips.Msi","Microsoft.VisualStudio.TestTools.TP.Legacy.Tips.Common","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.Tips","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.Tips.Resources","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.TestTools","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.Professional","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.Common","Microsoft.VisualStudio.TestTools.TP.Legacy.Common.Res","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.Core","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.Core.Resources","Microsoft.VisualStudio.TestTools.TestPlatform.Legacy.Agent","Microsoft.VisualStudio.PackageGroup.TestTools.TestPlatform.IDE","Microsoft.VisualStudio.TestTools.TestWIExtension","Microsoft.VisualStudio.TestTools.TestPlatform.IDE","Microsoft.VisualStudio.PackageGroup.TestTools.DataCollectors","Microsoft.Component.ClickOnce","Microsoft.VisualStudio.PackageGroup.ClickOnce.MSBuild","Microsoft.VisualCpp.CRT.ClickOnce.Msi","Microsoft.ClickOnce.SignTool.Msi","Microsoft.SQL.ClickOnceBootstrapper.Msi","Microsoft.Net.ClickOnceBootstrapper","Microsoft.ClickOnce.BootStrapper.Msi.Resources","Microsoft.ClickOnce.BootStrapper.Msi","Microsoft.VisualStudio.WebTools.WSP.FSA","Microsoft.VisualStudio.WebTools.WSP.FSA.Resources","Microsoft.VisualStudio.PackageGroup.Community","Microsoft.VisualStudio.Community.Extra.Resources","Microsoft.VisualStudio.Community.Extra","Microsoft.VisualStudio.PackageGroup.Core","Microsoft.VisualStudio.TestTools.TeamFoundationClient","Microsoft.VisualStudio.PackageGroup.Debugger.Core","Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost","Microsoft.VisualStudio.VC.Ide.Debugger","Microsoft.VisualStudio.VC.Ide.Debugger.Resources","Microsoft.VisualStudio.VC.Ide.Common","Microsoft.VisualStudio.VC.Ide.Common.Resources","Microsoft.VisualStudio.Debugger.Parallel","Microsoft.VisualStudio.Debugger.Parallel.Resources","Microsoft.VisualStudio.Debugger.CollectionAgents","Microsoft.VisualStudio.Debugger.Managed","Microsoft.CodeAnalysis.VisualStudio.Setup.Resources","Microsoft.CodeAnalysis.VisualStudio.Setup","Microsoft.CodeAnalysis.ExpressionEvaluator.Resources","Microsoft.CodeAnalysis.ExpressionEvaluator","Microsoft.VisualStudio.Debugger.Managed.Resources","Microsoft.VisualStudio.Debugger.Remote","Microsoft.VisualStudio.Debugger.Remote","Microsoft.VisualStudio.Debugger.Remote.Resources","Microsoft.VisualStudio.Debugger.Remote.Resources","Microsoft.VisualStudio.Debugger","Microsoft.VisualStudio.VC.MSVCDis","Microsoft.VisualStudio.ScriptedHost","Microsoft.VisualStudio.ScriptedHost.Targeted","Microsoft.VisualStudio.ScriptedHost.Resources","Microsoft.IntelliTrace.DiagnosticsHub","Microsoft.VisualStudio.Debugger.Resources","Microsoft.PackageGroup.ClientDiagnostics","Microsoft.VisualStudio.AppResponsiveness","Microsoft.VisualStudio.AppResponsiveness.Targeted","Microsoft.VisualStudio.AppResponsiveness.Resources","Microsoft.VisualStudio.ClientDiagnostics","Microsoft.VisualStudio.ClientDiagnostics.Targeted","Microsoft.VisualStudio.ClientDiagnostics.Resources","Microsoft.VisualStudio.PackageGroup.CommunityCore","Microsoft.VisualStudio.ProjectSystem.Full","Microsoft.VisualStudio.ProjectSystem","Microsoft.VisualStudio.Community.x86","Microsoft.VisualStudio.Community.x64","Microsoft.VisualStudio.Community","Microsoft.IntelliTrace.CollectorCab","Microsoft.VisualStudio.Community.Resources","Microsoft.VisualStudio.Net.Eula.Resources","Microsoft.VisualStudio.WebSiteProject.DTE","Microsoft.MSHtml","Microsoft.VisualStudio.Community.Msi.Resources","Microsoft.VisualStudio.Community.Msi","Microsoft.VisualStudio.MinShell.Interop.Msi","Microsoft.VisualStudio.Editors","Microsoft.VisualStudio.ClickOnce.Resources","Microsoft.VisualStudio.ClickOnce","Microsoft.Component.MSBuild","Microsoft.NuGet.Build.Tasks","Microsoft.VisualStudio.Component.Roslyn.Compiler","Microsoft.CodeAnalysis.Compilers.Resources","Microsoft.CodeAnalysis.Compilers","Microsoft.Net.PackageGroup.4.6.1.Redist","Microsoft.VisualStudio.TemplateEngine","Microsoft.VisualStudio.WebToolsExtensions.Common","Microsoft.NET.Sdk","Microsoft.VisualStudio.PackageGroup.TestTools.Templates.Managed","Microsoft.VisualStudio.TestTools.Templates.Managed","Microsoft.VisualStudio.TestTools.Templates.Managed.Resources","Microsoft.VisualStudio.Templates.VB.MSTestv2.Desktop.UnitTest","Microsoft.VisualStudio.Templates.CS.MSTestv2.Desktop.UnitTest","Microsoft.VisualStudio.Templates.VB.Wpf","Microsoft.VisualStudio.Templates.VB.Wpf.Resources","Microsoft.VisualStudio.Templates.VB.Winforms","Microsoft.VisualStudio.Templates.VB.ManagedCore","Microsoft.VisualStudio.Templates.VB.Shared","Microsoft.VisualStudio.Templates.VB.Shared.Resources","Microsoft.VisualStudio.Templates.VB.ManagedCore.Resources","Microsoft.VisualStudio.Templates.CS.GettingStarted.Desktop.Package","Microsoft.VisualStudio.Templates.GetStarted.Desktop.Setup","Microsoft.VisualStudio.Templates.CS.GettingStarted.Console.Package","Microsoft.VisualStudio.Templates.GetStarted.Resources","Microsoft.VisualStudio.Templates.GetStarted.Common.Setup","Microsoft.VisualStudio.Templates.GetStarted.Console.Setup","Microsoft.VisualStudio.Templates.CS.Wpf","Microsoft.VisualStudio.Templates.CS.Wpf.Resources","Microsoft.VisualStudio.Templates.CS.Winforms","Microsoft.VisualStudio.Templates.CS.ManagedCore","Microsoft.VisualStudio.Templates.CS.Shared","Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Setup","Templates.Editorconfig.SolutionFile.Setup","Microsoft.VisualStudio.Templates.CS.Shared.Resources","Microsoft.VisualStudio.Templates.CS.ManagedCore.Resources","Microsoft.VisualStudio.Component.CoreEditor","Microsoft.VisualStudio.PackageGroup.CoreEditor","PortableFacades","Microsoft.VisualStudio.PackageGroup.VsDevCmd","Microsoft.VisualStudio.VsDevCmd.Ext.NetFxSdk","Microsoft.VisualStudio.VsDevCmd.Core.WinSdk","Microsoft.VisualStudio.VsDevCmd.Core.DotNet","Microsoft.VisualStudio.VC.DevCmd","Microsoft.VisualStudio.VC.DevCmd.Resources","Microsoft.VisualStudio.VirtualTree","Microsoft.VisualStudio.PackageGroup.Progression","Microsoft.VisualStudio.PerformanceProvider","Microsoft.VisualStudio.GraphModel","Microsoft.VisualStudio.GraphProvider","Microsoft.DiaSymReader","Microsoft.Build.Dependencies","Microsoft.Build.FileTracker.Msi","Microsoft.Build","Microsoft.VisualStudio.TextMateGrammars","Microsoft.VisualStudio.PackageGroup.TeamExplorer","Microsoft.TeamFoundation.OfficeIntegration","Microsoft.TeamFoundation.OfficeIntegration.Resources","Microsoft.VisualStudio.TeamExplorer","Microsoft.ServiceHub","Microsoft.VisualStudio.ProjectServices","Microsoft.VisualStudio.SLNX.VSIX","Microsoft.VisualStudio.FileHandler.Msi","Microsoft.VisualStudio.FileHandler.Msi","Microsoft.VisualStudio.PackageGroup.MinShell","Microsoft.VisualStudio.MinShell.Interop","Microsoft.VisualStudio.Log","Microsoft.VisualStudio.Log.Targeted","Microsoft.VisualStudio.Log.Resources","Microsoft.VisualStudio.Finalizer","Microsoft.VisualStudio.WDExpress","Microsoft.VisualStudio.WDExpress.Resources","Microsoft.VisualStudio.CoreEditor","Microsoft.VisualStudio.Connected","Microsoft.VisualStudio.Connected.Resources","Microsoft.VisualStudio.MinShell","Microsoft.VisualStudio.Setup.Configuration","Microsoft.VisualStudio.MinShell.Platform","Microsoft.VisualStudio.MinShell.Platform.Resources","Microsoft.VisualStudio.MefHosting","Microsoft.VisualStudio.MefHosting.Resources","Microsoft.VisualStudio.Initializer","Microsoft.VisualStudio.ExtensionManager","Microsoft.VisualStudio.MinShell.x86","Microsoft.VisualStudio.NativeImageSupport","Microsoft.VisualStudio.MinShell.Msi","Microsoft.VisualStudio.MinShell.Msi.Resources","Microsoft.VisualStudio.LanguageServer","Microsoft.VisualStudio.MinShell.Resources","Microsoft.Net.PackageGroup.4.6.Redist","Microsoft.VisualStudio.Branding.WDExpress"]}] diff --git a/node_modules/node-gyp/test/process-exec-sync.js b/node_modules/node-gyp/test/process-exec-sync.js index f786484027cde..21763bc26de10 100644 --- a/node_modules/node-gyp/test/process-exec-sync.js +++ b/node_modules/node-gyp/test/process-exec-sync.js @@ -67,7 +67,7 @@ function processExecSync (file, args, options) { } } - [ 'stdout', 'stderr', 'status' ].forEach(function (file) { + ['stdout', 'stderr', 'status'].forEach(function (file) { child[file] = fs.readFileSync(tmpdir + '/' + file, options.encoding) setTimeout(unlinkFile, 500, tmpdir + '/' + file) }) diff --git a/node_modules/node-gyp/test/test-addon.js b/node_modules/node-gyp/test/test-addon.js index f97215c0a2652..f79eff73c169e 100644 --- a/node_modules/node-gyp/test/test-addon.js +++ b/node_modules/node-gyp/test/test-addon.js @@ -15,18 +15,18 @@ function runHello (hostProcess) { hostProcess = process.execPath } var testCode = "console.log(require('hello_world').hello())" - return execFileSync(hostProcess, [ '-e', testCode ], { cwd: __dirname }).toString() + return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString() } function getEncoding () { var code = 'import locale;print(locale.getdefaultlocale()[1])' - return execFileSync('python', [ '-c', code ]).toString().trim() + return execFileSync('python', ['-c', code]).toString().trim() } function checkCharmapValid () { var data try { - data = execFileSync('python', [ 'fixtures/test-charmap.py' ], + data = execFileSync('python', ['fixtures/test-charmap.py'], { cwd: __dirname }) } catch (err) { return false @@ -39,7 +39,7 @@ test('build simple addon', function (t) { t.plan(3) // Set the loglevel otherwise the output disappears when run via 'npm test' - var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ] + var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose'] var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) { var logLines = stderr.toString().trim().split(/\r?\n/) var lastLine = logLines[logLines.length - 1] @@ -59,9 +59,9 @@ test('build simple addon in path with non-ascii characters', function (t) { } var testDirNames = { - 'cp936': '文件夹', - 'cp1252': 'Latīna', - 'cp932': 'フォルダ' + cp936: '文件夹', + cp1252: 'Latīna', + cp932: 'フォルダ' } // Select non-ascii characters by current encoding var testDirName = testDirNames[getEncoding()] @@ -136,7 +136,7 @@ test('addon works with renamed host executable', function (t) { var notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath)) fs.copyFileSync(process.execPath, notNodePath) - var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ] + var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose'] var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) { var logLines = stderr.toString().trim().split(/\r?\n/) var lastLine = logLines[logLines.length - 1] diff --git a/node_modules/node-gyp/test/test-configure-python.js b/node_modules/node-gyp/test/test-configure-python.js index 41b8c70427336..518bf036d0ecb 100644 --- a/node_modules/node-gyp/test/test-configure-python.js +++ b/node_modules/node-gyp/test/test-configure-python.js @@ -6,10 +6,10 @@ const gyp = require('../lib/node-gyp') const requireInject = require('require-inject') const configure = requireInject('../lib/configure', { 'graceful-fs': { - 'openSync': function () { return 0 }, - 'closeSync': function () { }, - 'writeFile': function (file, data, cb) { cb() }, - 'stat': function (file, cb) { cb(null, {}) } + openSync: function () { return 0 }, + closeSync: function () { }, + writeFile: function (file, data, cb) { cb() }, + stat: function (file, cb) { cb(null, {}) } } }) @@ -42,10 +42,10 @@ test('configure PYTHONPATH with existing env of one dir', function (t) { var prog = gyp() prog.parseArgv([]) prog.spawn = function () { - t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR)) + t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR)) var dirs = process.env.PYTHONPATH.split(SEPARATOR) - t.deepEqual(dirs, [ EXPECTED_PYPATH, existingPath ]) + t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath]) return SPAWN_RESULT } @@ -57,16 +57,16 @@ test('configure PYTHONPATH with existing env of multiple dirs', function (t) { var pythonDir1 = path.join('a', 'b') var pythonDir2 = path.join('b', 'c') - var existingPath = [ pythonDir1, pythonDir2 ].join(SEPARATOR) + var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR) process.env.PYTHONPATH = existingPath var prog = gyp() prog.parseArgv([]) prog.spawn = function () { - t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR)) + t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR)) var dirs = process.env.PYTHONPATH.split(SEPARATOR) - t.deepEqual(dirs, [ EXPECTED_PYPATH, pythonDir1, pythonDir2 ]) + t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2]) return SPAWN_RESULT } diff --git a/node_modules/node-gyp/test/test-find-accessible-sync.js b/node_modules/node-gyp/test/test-find-accessible-sync.js index 32234f5389c1d..0a2e584c4fb33 100644 --- a/node_modules/node-gyp/test/test-find-accessible-sync.js +++ b/node_modules/node-gyp/test/test-find-accessible-sync.js @@ -5,8 +5,8 @@ const path = require('path') const requireInject = require('require-inject') const configure = requireInject('../lib/configure', { 'graceful-fs': { - 'closeSync': function () { return undefined }, - 'openSync': function (path) { + closeSync: function () { return undefined }, + openSync: function (path) { if (readableFiles.some(function (f) { return f === path })) { return 0 } else { @@ -38,7 +38,7 @@ test('find accessible - empty array', function (t) { test('find accessible - single item array, readable', function (t) { t.plan(1) - var candidates = [ readableFile ] + var candidates = [readableFile] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, readableFile)) }) @@ -46,7 +46,7 @@ test('find accessible - single item array, readable', function (t) { test('find accessible - single item array, readable in subdir', function (t) { t.plan(1) - var candidates = [ readableFileInDir ] + var candidates = [readableFileInDir] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, readableFileInDir)) }) @@ -54,7 +54,7 @@ test('find accessible - single item array, readable in subdir', function (t) { test('find accessible - single item array, unreadable', function (t) { t.plan(1) - var candidates = [ 'unreadable_file' ] + var candidates = ['unreadable_file'] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, undefined) }) @@ -62,7 +62,7 @@ test('find accessible - single item array, unreadable', function (t) { test('find accessible - multi item array, no matches', function (t) { t.plan(1) - var candidates = [ 'non_existent_file', 'unreadable_file' ] + var candidates = ['non_existent_file', 'unreadable_file'] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, undefined) }) @@ -70,7 +70,7 @@ test('find accessible - multi item array, no matches', function (t) { test('find accessible - multi item array, single match', function (t) { t.plan(1) - var candidates = [ 'non_existent_file', readableFile ] + var candidates = ['non_existent_file', readableFile] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, readableFile)) }) @@ -78,7 +78,7 @@ test('find accessible - multi item array, single match', function (t) { test('find accessible - multi item array, return first match', function (t) { t.plan(1) - var candidates = [ 'non_existent_file', anotherReadableFile, readableFile ] + var candidates = ['non_existent_file', anotherReadableFile, readableFile] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, anotherReadableFile)) }) diff --git a/node_modules/node-gyp/test/test-find-node-directory.js b/node_modules/node-gyp/test/test-find-node-directory.js index 767b6f6b37d20..f1380d162ae7c 100644 --- a/node_modules/node-gyp/test/test-find-node-directory.js +++ b/node_modules/node-gyp/test/test-find-node-directory.js @@ -4,7 +4,7 @@ const test = require('tap').test const path = require('path') const findNodeDirectory = require('../lib/find-node-directory') -const platforms = [ 'darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix' ] +const platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix'] // we should find the directory based on the directory // the script is running in and it should match the layout @@ -62,8 +62,10 @@ test('test find-node-directory - node in build release dir', function (t) { if (platforms[next] === 'win32') { processObj = { execPath: '/x/y/Release/node', platform: platforms[next] } } else { - processObj = { execPath: '/x/y/out/Release/node', - platform: platforms[next] } + processObj = { + execPath: '/x/y/out/Release/node', + platform: platforms[next] + } } t.equal( diff --git a/node_modules/node-gyp/test/test-find-visualstudio.js b/node_modules/node-gyp/test/test-find-visualstudio.js index b00adf022719a..1327cf8841111 100644 --- a/node_modules/node-gyp/test/test-find-visualstudio.js +++ b/node_modules/node-gyp/test/test-find-visualstudio.js @@ -296,6 +296,34 @@ test('VS2017 Community with C++ workload', function (t) { finder.findVisualStudio() }) +test('VS2017 Express', function (t) { + t.plan(2) + + const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => { + t.strictEqual(err, null) + t.deepEqual(info, { + msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\' + + 'WDExpress\\MSBuild\\15.0\\Bin\\MSBuild.exe', + path: + 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\WDExpress', + sdk: '10.0.17763.0', + toolset: 'v141', + version: '15.9.28307.858', + versionMajor: 15, + versionMinor: 9, + versionYear: 2017 + }) + }) + + poison(finder, 'regSearchKeys') + finder.findVisualStudio2017OrNewer = (cb) => { + const file = path.join(__dirname, 'fixtures', 'VS_2017_Express.txt') + const data = fs.readFileSync(file) + finder.parseData(null, data, '', cb) + } + finder.findVisualStudio() +}) + test('VS2019 Preview with C++ workload', function (t) { t.plan(2) @@ -392,13 +420,15 @@ function allVsVersions (t, finder) { const data2 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', 'VS_2017_Community_workload.txt'))) const data3 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', - 'VS_2019_Preview.txt'))) + 'VS_2017_Express.txt'))) const data4 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', - 'VS_2019_BuildTools_minimal.txt'))) + 'VS_2019_Preview.txt'))) const data5 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', + 'VS_2019_BuildTools_minimal.txt'))) + const data6 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', 'VS_2019_Community_workload.txt'))) const data = JSON.stringify(data0.concat(data1, data2, data3, data4, - data5)) + data5, data6)) finder.parseData(null, data, '', cb) } finder.regSearchKeys = (keys, value, addOpts, cb) => { diff --git a/node_modules/node-gyp/test/test-process-release.js b/node_modules/node-gyp/test/test-process-release.js index e4370e59eed9a..c3ee0703c532f 100644 --- a/node_modules/node-gyp/test/test-process-release.js +++ b/node_modules/node-gyp/test/test-process-release.js @@ -19,7 +19,8 @@ test('test process release - process.version = 0.8.20', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.8.20/SHASUMS256.txt', versionDir: '0.8.20', ia32: { libUrl: 'https://nodejs.org/dist/v0.8.20/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', libPath: 'x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', libPath: 'x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v0.8.20/arm64/node.lib', libPath: 'arm64/node.lib' } }) }) @@ -39,7 +40,8 @@ test('test process release - process.version = 0.10.21', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.10.21/SHASUMS256.txt', versionDir: '0.10.21', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.21/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', libPath: 'x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', libPath: 'x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v0.10.21/arm64/node.lib', libPath: 'arm64/node.lib' } }) }) @@ -60,7 +62,8 @@ test('test process release - process.version = 0.12.9', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.12.9/SHASUMS256.txt', versionDir: '0.12.9', ia32: { libUrl: 'https://nodejs.org/dist/v0.12.9/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.12.9/x64/node.lib', libPath: 'x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v0.12.9/x64/node.lib', libPath: 'x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v0.12.9/arm64/node.lib', libPath: 'arm64/node.lib' } }) }) @@ -81,7 +84,8 @@ test('test process release - process.version = 0.10.41', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.10.41/SHASUMS256.txt', versionDir: '0.10.41', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.41/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.41/x64/node.lib', libPath: 'x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v0.10.41/x64/node.lib', libPath: 'x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v0.10.41/arm64/node.lib', libPath: 'arm64/node.lib' } }) }) @@ -102,7 +106,8 @@ test('test process release - process.release ~ node@0.10.42', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.10.42/SHASUMS256.txt', versionDir: '0.10.42', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.42/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.42/x64/node.lib', libPath: 'x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v0.10.42/x64/node.lib', libPath: 'x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v0.10.42/arm64/node.lib', libPath: 'arm64/node.lib' } }) }) @@ -123,7 +128,8 @@ test('test process release - process.release ~ node@0.12.10', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.12.10/SHASUMS256.txt', versionDir: '0.12.10', ia32: { libUrl: 'https://nodejs.org/dist/v0.12.10/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.12.10/x64/node.lib', libPath: 'x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v0.12.10/x64/node.lib', libPath: 'x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v0.12.10/arm64/node.lib', libPath: 'arm64/node.lib' } }) }) @@ -146,7 +152,8 @@ test('test process release - process.release ~ node@4.1.23', function (t) { shasumsUrl: 'https://nodejs.org/dist/v4.1.23/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } }) }) @@ -169,7 +176,60 @@ test('test process release - process.release ~ node@4.1.23 / corp build', functi shasumsUrl: 'https://some.custom.location/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'https://some.custom.location/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://some.custom.location/win-x64/node.lib', libPath: 'win-x64/node.lib' } + x64: { libUrl: 'https://some.custom.location/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://some.custom.location/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } + }) +}) + +test('test process release - process.release ~ node@12.8.0 Windows', function (t) { + t.plan(2) + + var release = processRelease([], { opts: {} }, 'v12.8.0', { + name: 'node', + sourceUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0.tar.gz', + headersUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz', + libUrl: 'https://nodejs.org/download/release/v12.8.0/win-x64/node.lib' + }) + + t.equal(release.semver.version, '12.8.0') + delete release.semver + + t.deepEqual(release, { + version: '12.8.0', + name: 'node', + baseUrl: 'https://nodejs.org/download/release/v12.8.0/', + tarballUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz', + shasumsUrl: 'https://nodejs.org/download/release/v12.8.0/SHASUMS256.txt', + versionDir: '12.8.0', + ia32: { libUrl: 'https://nodejs.org/download/release/v12.8.0/win-x86/node.lib', libPath: 'win-x86/node.lib' }, + x64: { libUrl: 'https://nodejs.org/download/release/v12.8.0/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/download/release/v12.8.0/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } + }) +}) + +test('test process release - process.release ~ node@12.8.0 Windows ARM64', function (t) { + t.plan(2) + + var release = processRelease([], { opts: {} }, 'v12.8.0', { + name: 'node', + sourceUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0.tar.gz', + headersUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz', + libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-arm64/node.lib' + }) + + t.equal(release.semver.version, '12.8.0') + delete release.semver + + t.deepEqual(release, { + version: '12.8.0', + name: 'node', + baseUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/', + tarballUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz', + shasumsUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/SHASUMS256.txt', + versionDir: '12.8.0', + ia32: { libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-x86/node.lib', libPath: 'win-x86/node.lib' }, + x64: { libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } }) }) @@ -192,7 +252,8 @@ test('test process release - process.release ~ node@4.1.23 --target=0.10.40', fu shasumsUrl: 'https://nodejs.org/dist/v0.10.40/SHASUMS256.txt', versionDir: '0.10.40', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.40/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', libPath: 'x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', libPath: 'x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/dist/v0.10.40/arm64/node.lib', libPath: 'arm64/node.lib' } }) }) @@ -215,7 +276,8 @@ test('test process release - process.release ~ node@4.1.23 --dist-url=https://fo shasumsUrl: 'https://foo.bar/baz/v4.1.23/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' } + x64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } }) }) @@ -238,7 +300,8 @@ test('test process release - process.release ~ frankenstein@4.1.23', function (t shasumsUrl: 'https://frankensteinjs.org/dist/v4.1.23/SHASUMS256.txt', versionDir: 'frankenstein-4.1.23', ia32: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' }, - x64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' } + x64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' }, + arm64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-arm64/frankenstein.lib', libPath: 'win-arm64/frankenstein.lib' } }) }) @@ -261,7 +324,8 @@ test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=ht shasumsUrl: 'http://foo.bar/baz/v4.1.23/SHASUMS256.txt', versionDir: 'frankenstein-4.1.23', ia32: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' }, - x64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' } + x64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' }, + arm64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-arm64/frankenstein.lib', libPath: 'win-arm64/frankenstein.lib' } }) }) @@ -284,7 +348,8 @@ test('test process release - process.release ~ node@4.0.0-rc.4', function (t) { shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', versionDir: '4.0.0-rc.4', ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } }) }) @@ -293,7 +358,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0] // note the missing 'v' on the arg, it should normalise when checking // whether we're on the default or not - var release = processRelease([ '4.0.0-rc.4' ], { opts: {} }, 'v4.0.0-rc.4', { + var release = processRelease(['4.0.0-rc.4'], { opts: {} }, 'v4.0.0-rc.4', { name: 'node', headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz' }) @@ -309,7 +374,8 @@ test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0] shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', versionDir: '4.0.0-rc.4', ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } }) }) @@ -318,7 +384,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string pa // additional arguments can be passed in on the commandline that should be ignored if they // are not specifying a valid version @ position 0 - var release = processRelease([ 'this is no version!' ], { opts: {} }, 'v4.0.0-rc.4', { + var release = processRelease(['this is no version!'], { opts: {} }, 'v4.0.0-rc.4', { name: 'node', headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz' }) @@ -334,7 +400,8 @@ test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string pa shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', versionDir: '4.0.0-rc.4', ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' } + x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } }) }) @@ -359,7 +426,8 @@ test('test process release - NODEJS_ORG_MIRROR', function (t) { shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'http://foo.bar/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' } + x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'http://foo.bar/v4.1.23/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } }) delete process.env.NODEJS_ORG_MIRROR diff --git a/package-lock.json b/package-lock.json index 94d05d15c31ba..9edc5d9e4ac9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3695,9 +3695,9 @@ } }, "node-gyp": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.4.tgz", - "integrity": "sha512-PMYap4ekQckQDZ2lxoORUF/nX13haU1JdCAlmLgvrykLyN0LFkhfwPbWhYjTxwTruCWbTkeOxFo043kjhmKHZA==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.5.tgz", + "integrity": "sha512-WABl9s4/mqQdZneZHVWVG4TVr6QQJZUC6PAx47ITSk9lreZ1n+7Z9mMAIbA3vnO4J9W20P7LhCxtzfWsAD/KDw==", "requires": { "env-paths": "^1.0.0", "glob": "^7.0.3", diff --git a/package.json b/package.json index e45da2e2f4526..7a1e8cefc334c 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "mississippi": "^3.0.0", "mkdirp": "~0.5.1", "move-concurrently": "^1.0.1", - "node-gyp": "^5.0.4", + "node-gyp": "^5.0.5", "nopt": "~4.0.1", "normalize-package-data": "^2.5.0", "npm-audit-report": "^1.3.2", From 3547d99892a3da43831ad74b47488750d4f2da36 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Fri, 4 Oct 2019 09:36:04 -0400 Subject: [PATCH 21/27] Removes warnings from package manifest --- lib/install/validate-tree.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/install/validate-tree.js b/lib/install/validate-tree.js index 5ac979a46c403..d1b40c24c1bcb 100644 --- a/lib/install/validate-tree.js +++ b/lib/install/validate-tree.js @@ -39,8 +39,9 @@ function checkErrors (mod, idealTree, next) { function checkWarnings (mod, idealTree, next) { const warnings = mod.package.warnings - if (warnings && (mod.parent || path.resolve(npm.globalDir, '..'))) { + if (warnings && (mod.parent || path.resolve(npm.globalDir, '..') !== mod.path)) { warnings.forEach(warn => idealTree.warnings.push(warn)) + delete mod.package.warnings } next() } From f3299acd0b4249500e940776aca77cc6c0977263 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Fri, 4 Oct 2019 10:23:50 -0400 Subject: [PATCH 22/27] Reimplemented using idealTree param PR-URL: https://github.com/npm/cli/pull/257 Credit: @ruyadorno Close: #257 Reviewed-by: @isaacs --- lib/install/actions.js | 2 +- lib/install/deps.js | 2 +- lib/install/validate-args.js | 21 +++++++---- lib/install/validate-tree.js | 12 +------ test/tap/check-engine-reqs.js | 6 ++-- test/tap/validate-tree-check-warnings.js | 44 ------------------------ 6 files changed, 20 insertions(+), 67 deletions(-) delete mode 100644 test/tap/validate-tree-check-warnings.js diff --git a/lib/install/actions.js b/lib/install/actions.js index a34d03ffe2146..e26432b77c86a 100644 --- a/lib/install/actions.js +++ b/lib/install/actions.js @@ -49,7 +49,7 @@ Object.keys(actions).forEach(function (actionName) { if (pkg.knownInstallable) { actionP = runAction(action, staging, pkg, log) } else { - actionP = isInstallable(pkg.package).then(() => { + actionP = isInstallable(null, pkg.package).then(() => { pkg.knownInstallable = true return runAction(action, staging, pkg, log) }) diff --git a/lib/install/deps.js b/lib/install/deps.js index bfc94ae504860..dfe30b6c0f38c 100644 --- a/lib/install/deps.js +++ b/lib/install/deps.js @@ -665,7 +665,7 @@ function resolveWithNewModule (pkg, tree, log, next) { validate('OOOF', arguments) log.silly('resolveWithNewModule', packageId(pkg), 'checking installable status') - return isInstallable(pkg, (err) => { + return isInstallable(tree, pkg, (err) => { let installable = !err addBundled(pkg, (bundleErr) => { var parent = earliestInstallable(tree, tree, pkg, log) || tree diff --git a/lib/install/validate-args.js b/lib/install/validate-args.js index 386cce3ca939c..b680a1b24ba47 100644 --- a/lib/install/validate-args.js +++ b/lib/install/validate-args.js @@ -16,7 +16,7 @@ module.exports = function (idealTree, args, next) { chain([ [hasMinimumFields, pkg], [checkSelf, idealTree, pkg, force], - [isInstallable, pkg] + [isInstallable, idealTree, pkg] ], done) }, next) } @@ -31,17 +31,24 @@ function hasMinimumFields (pkg, cb) { } } -function setWarnings (pkg, warn) { - if (!pkg.warnings) pkg.warnings = [] - if (pkg.warnings.every(i => ( +function setWarnings (idealTree, warn) { + function top (tree) { + if (tree.parent) return top(tree.parent) + return tree + } + + var topTree = top(idealTree) + if (!topTree.warnings) topTree.warnings = [] + + if (topTree.warnings.every(i => ( i.code !== warn.code || i.required !== warn.required || i.pkgid !== warn.pkgid))) { - pkg.warnings.push(warn) + topTree.warnings.push(warn) } } -var isInstallable = module.exports.isInstallable = function (pkg, next) { +var isInstallable = module.exports.isInstallable = function (idealTree, pkg, next) { var force = npm.config.get('force') var nodeVersion = npm.config.get('node-version') if (/-/.test(nodeVersion)) { @@ -52,7 +59,7 @@ var isInstallable = module.exports.isInstallable = function (pkg, next) { var strict = npm.config.get('engine-strict') checkEngine(pkg, npm.version, nodeVersion, force, strict, iferr(next, thenWarnEngineIssues)) function thenWarnEngineIssues (warn) { - if (warn) setWarnings(pkg, warn) + if (idealTree && warn) setWarnings(idealTree, warn) checkPlatform(pkg, force, next) } } diff --git a/lib/install/validate-tree.js b/lib/install/validate-tree.js index d1b40c24c1bcb..24a140171d45c 100644 --- a/lib/install/validate-tree.js +++ b/lib/install/validate-tree.js @@ -22,8 +22,7 @@ module.exports = function (idealTree, log, next) { [asyncMap, modules, function (mod, done) { chain([ mod.parent && !mod.isLink && [checkGit, mod.realpath], - [checkErrors, mod, idealTree], - [checkWarnings, mod, idealTree] + [checkErrors, mod, idealTree] ], done) }], [thenValidateAllPeerDeps, idealTree], @@ -37,15 +36,6 @@ function checkErrors (mod, idealTree, next) { next() } -function checkWarnings (mod, idealTree, next) { - const warnings = mod.package.warnings - if (warnings && (mod.parent || path.resolve(npm.globalDir, '..') !== mod.path)) { - warnings.forEach(warn => idealTree.warnings.push(warn)) - delete mod.package.warnings - } - next() -} - function thenValidateAllPeerDeps (idealTree, next) { validate('OF', arguments) validateAllPeerDeps(idealTree, function (tree, pkgname, version) { diff --git a/test/tap/check-engine-reqs.js b/test/tap/check-engine-reqs.js index 7ebb29484d828..fa25e28dd60ed 100644 --- a/test/tap/check-engine-reqs.js +++ b/test/tap/check-engine-reqs.js @@ -47,9 +47,9 @@ test('warns on bad engine not strict', function (t) { t.ifError(err, 'npm ran without issue') t.is(code, 0, 'result code') var result = JSON.parse(stdout) - t.match(result.warnings[1], /Unsupported engine/, 'reason for optional failure in JSON') - t.match(result.warnings[1], /1.0.0-not-a-real-version/, 'should print mismatch version info') - t.match(result.warnings[1], /Not compatible with your version of node/, 'incompatibility message') + t.match(result.warnings[0], /Unsupported engine/, 'reason for optional failure in JSON') + t.match(result.warnings[0], /1.0.0-not-a-real-version/, 'should print mismatch version info') + t.match(result.warnings[0], /Not compatible with your version of node/, 'incompatibility message') t.done() }) }) diff --git a/test/tap/validate-tree-check-warnings.js b/test/tap/validate-tree-check-warnings.js deleted file mode 100644 index 7b0bd45359d2c..0000000000000 --- a/test/tap/validate-tree-check-warnings.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict' -var test = require('tap').test -var log = require('npmlog') -var npm = require('../../lib/npm.js') -var checkEngine = require('npm-install-checks').checkEngine - -var idealTree = { - package: { - name: 'a b c', - version: '3.what' - }, - children: [{ - name: 'faulty-engine', - version: '0.0.1', - children: [], - engines: { - node: '>=2.0.0' - }, - package: { - name: 'faulty-engine', - version: '0.0.1' - } - }], - warnings: [] -} - -test('setup', function (t) { - const faultyEnginePkg = idealTree.children[0] - checkEngine(faultyEnginePkg, '1.0.0', '1.0.0', false, false, (err, warn) => { - t.ifError(err, 'check engine ran without issue') - faultyEnginePkg.package.warnings = [warn] - npm.load({}, t.end) - }) -}) - -test('validate-tree should collect warnings from modules', function (t) { - log.disableProgress() - var validateTree = require('../../lib/install/validate-tree.js') - validateTree(idealTree, log.newGroup('validate'), function (er, a, b) { - t.equal(idealTree.warnings[0].code, 'ENOTSUP', 'should have the correct error') - t.match(idealTree.warnings[0].message, /Unsupported engine/, 'reason for optional failure in JSON') - t.end() - }) -}) From f46edae9450b707650a0efab09aa1e9295a18070 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 7 Oct 2019 16:34:36 -0700 Subject: [PATCH 23/27] hosted-git-info@2.8.5 --- node_modules/hosted-git-info/CHANGELOG.md | 21 ++++++++++++++ node_modules/hosted-git-info/git-host-info.js | 2 +- node_modules/hosted-git-info/git-host.js | 4 +-- node_modules/hosted-git-info/index.js | 11 ++++---- node_modules/hosted-git-info/package.json | 28 +++++++++---------- package-lock.json | 9 ++---- package.json | 2 +- 7 files changed, 47 insertions(+), 30 deletions(-) diff --git a/node_modules/hosted-git-info/CHANGELOG.md b/node_modules/hosted-git-info/CHANGELOG.md index 9eedbb80b1ecc..479f24b6414eb 100644 --- a/node_modules/hosted-git-info/CHANGELOG.md +++ b/node_modules/hosted-git-info/CHANGELOG.md @@ -2,6 +2,27 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.8.5](https://github.com/npm/hosted-git-info/compare/v2.8.4...v2.8.5) (2019-10-07) + + +### Bug Fixes + +* updated pathmatch for gitlab ([e8325b5](https://github.com/npm/hosted-git-info/commit/e8325b5)), closes [#51](https://github.com/npm/hosted-git-info/issues/51) +* updated pathmatch for gitlab ([ffe056f](https://github.com/npm/hosted-git-info/commit/ffe056f)) + + + + +## [2.8.4](https://github.com/npm/hosted-git-info/compare/v2.8.3...v2.8.4) (2019-08-12) + + + + +## [2.8.3](https://github.com/npm/hosted-git-info/compare/v2.8.2...v2.8.3) (2019-08-12) + + + ## [2.8.2](https://github.com/npm/hosted-git-info/compare/v2.8.1...v2.8.2) (2019-08-05) diff --git a/node_modules/hosted-git-info/git-host-info.js b/node_modules/hosted-git-info/git-host-info.js index d81be2050cd56..8147e3348f5e8 100644 --- a/node_modules/hosted-git-info/git-host-info.js +++ b/node_modules/hosted-git-info/git-host-info.js @@ -25,7 +25,7 @@ var gitHosts = module.exports = { 'bugstemplate': 'https://{domain}/{user}/{project}/issues', 'httpstemplate': 'git+https://{auth@}{domain}/{user}/{projectPath}.git{#committish}', 'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}', - 'pathmatch': /^[/]([^/]+)[/](.+?)(?:[.]git|[/])?$/ + 'pathmatch': /^[/]([^/]+)[/]((?!.*(\/-\/|\/repository\/archive\.tar\.gz\?=.*|\/repository\/[^/]+\/archive.tar.gz$)).*?)(?:[.]git|[/])?$/ }, gist: { 'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ], diff --git a/node_modules/hosted-git-info/git-host.js b/node_modules/hosted-git-info/git-host.js index ee5bb1af0ae9e..9616fbaa6b4af 100644 --- a/node_modules/hosted-git-info/git-host.js +++ b/node_modules/hosted-git-info/git-host.js @@ -9,8 +9,8 @@ var extend = Object.assign || function _extend (target, source) { // Don't do anything if source isn't an object if (source === null || typeof source !== 'object') return target - const keys = Object.keys(source) - let i = keys.length + var keys = Object.keys(source) + var i = keys.length while (i--) { target[keys[i]] = source[keys[i]] } diff --git a/node_modules/hosted-git-info/index.js b/node_modules/hosted-git-info/index.js index adae4604c4dbd..fc959cb0434c8 100644 --- a/node_modules/hosted-git-info/index.js +++ b/node_modules/hosted-git-info/index.js @@ -2,8 +2,6 @@ var url = require('url') var gitHosts = require('./git-host-info.js') var GitHost = module.exports = require('./git-host.js') -var LRU = require('lru-cache') -var cache = new LRU({max: 1000}) var protocolToRepresentationMap = { 'git+ssh:': 'sshurl', @@ -24,15 +22,17 @@ var authProtocols = { 'git+http:': true } +var cache = {} + module.exports.fromUrl = function (giturl, opts) { if (typeof giturl !== 'string') return var key = giturl + JSON.stringify(opts || {}) - if (!cache.has(key)) { - cache.set(key, fromUrl(giturl, opts)) + if (!(key in cache)) { + cache[key] = fromUrl(giturl, opts) } - return cache.get(key) + return cache[key] } function fromUrl (giturl, opts) { @@ -64,6 +64,7 @@ function fromUrl (giturl, opts) { var pathmatch = gitHostInfo.pathmatch var matched = parsed.path.match(pathmatch) if (!matched) return + /* istanbul ignore else */ if (matched[1] !== null && matched[1] !== undefined) { user = decodeURIComponent(matched[1].replace(/^:/, '')) } diff --git a/node_modules/hosted-git-info/package.json b/node_modules/hosted-git-info/package.json index 86e7ba59a7c9c..458b323a40518 100644 --- a/node_modules/hosted-git-info/package.json +++ b/node_modules/hosted-git-info/package.json @@ -1,19 +1,19 @@ { - "_from": "hosted-git-info@2.8.2", - "_id": "hosted-git-info@2.8.2", + "_from": "hosted-git-info@2.8.5", + "_id": "hosted-git-info@2.8.5", "_inBundle": false, - "_integrity": "sha512-CyjlXII6LMsPMyUzxpTt8fzh5QwzGqPmQXgY/Jyf4Zfp27t/FvfhwoE/8laaMUcMy816CkWF20I7NeQhwwY88w==", + "_integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", "_location": "/hosted-git-info", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "hosted-git-info@2.8.2", + "raw": "hosted-git-info@2.8.5", "name": "hosted-git-info", "escapedName": "hosted-git-info", - "rawSpec": "2.8.2", + "rawSpec": "2.8.5", "saveSpec": null, - "fetchSpec": "2.8.2" + "fetchSpec": "2.8.5" }, "_requiredBy": [ "#USER", @@ -21,9 +21,9 @@ "/normalize-package-data", "/npm-package-arg" ], - "_resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.2.tgz", - "_shasum": "a35c3f355ac1249f1093c0c2a542ace8818c171a", - "_spec": "hosted-git-info@2.8.2", + "_resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "_shasum": "759cfcf2c4d156ade59b0b2dfabddc42a6b9c70c", + "_spec": "hosted-git-info@2.8.5", "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Rebecca Turner", @@ -34,9 +34,6 @@ "url": "https://github.com/npm/hosted-git-info/issues" }, "bundleDependencies": false, - "dependencies": { - "lru-cache": "^5.1.1" - }, "deprecated": false, "description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab", "devDependencies": { @@ -64,11 +61,12 @@ "url": "git+https://github.com/npm/hosted-git-info.git" }, "scripts": { - "postrelease": "npm publish && git push --follow-tags", + "postrelease": "npm publish --tag=ancient-legacy-fixes && git push --follow-tags", "prerelease": "npm t", "pretest": "standard", "release": "standard-version -s", - "test": "tap -J --100 --no-esm test/*.js" + "test": "tap -J --100 --no-esm test/*.js", + "test:coverage": "tap --coverage-report=html -J --100 --no-esm test/*.js" }, - "version": "2.8.2" + "version": "2.8.5" } diff --git a/package-lock.json b/package-lock.json index 9edc5d9e4ac9a..7350b6bf7eaba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2477,12 +2477,9 @@ } }, "hosted-git-info": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.2.tgz", - "integrity": "sha512-CyjlXII6LMsPMyUzxpTt8fzh5QwzGqPmQXgY/Jyf4Zfp27t/FvfhwoE/8laaMUcMy816CkWF20I7NeQhwwY88w==", - "requires": { - "lru-cache": "^5.1.1" - } + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==" }, "http-cache-semantics": { "version": "3.8.1", diff --git a/package.json b/package.json index 7a1e8cefc334c..3a8435c64bd98 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "glob": "^7.1.4", "graceful-fs": "^4.2.2", "has-unicode": "~2.0.1", - "hosted-git-info": "^2.8.2", + "hosted-git-info": "^2.8.5", "iferr": "^1.0.2", "infer-owner": "^1.0.4", "inflight": "~1.0.6", From 70f54dcb5693b301c6b357922b7e8d16b57d8b00 Mon Sep 17 00:00:00 2001 From: Henrik Gemal Date: Wed, 28 Aug 2019 09:37:57 +0200 Subject: [PATCH 24/27] Make OK more consistent PR-URL: https://github.com/npm/cli/pull/241 Credit: @gemal Close: #241 Reviewed-by: @isaacs --- lib/doctor/check-ping.js | 2 +- test/tap/doctor.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/doctor/check-ping.js b/lib/doctor/check-ping.js index 70db255480c37..58f14fe69e1e0 100644 --- a/lib/doctor/check-ping.js +++ b/lib/doctor/check-ping.js @@ -8,7 +8,7 @@ function checkPing (cb) { if (err && err.code && err.code.match(/^E\d{3}$/)) { return cb(null, [err.code.substr(1)]) } else { - cb(null, [200, 'OK']) + cb(null, [200, 'ok']) } }) } diff --git a/test/tap/doctor.js b/test/tap/doctor.js index 9285518c2e10e..9a1b42cdd5361 100644 --- a/test/tap/doctor.js +++ b/test/tap/doctor.js @@ -92,7 +92,7 @@ t.test('npm doctor', function (t) { npm.commands.doctor({'node-url': node_url}, true, function (e, list) { t.ifError(e, 'npm loaded successfully') t.same(list.length, 9, 'list should have 9 prop') - t.same(list[0][1], 'OK', 'npm ping') + t.same(list[0][1], 'ok', 'npm ping') t.same(list[1][1], 'v' + npm.version, 'npm -v') t.same(list[2][1], process.version, 'node -v') t.same(list[3][1], common.registry + '/', 'npm config get registry') @@ -113,7 +113,7 @@ t.test('npm doctor works without registry', function (t) { npm.commands.doctor({'node-url': node_url}, true, function (e, list) { t.ifError(e, 'npm loaded successfully') t.same(list.length, 9, 'list should have 9 prop') - t.same(list[0][1], 'OK', 'npm ping') + t.same(list[0][1], 'ok', 'npm ping') t.same(list[1][1], 'v' + npm.version, 'npm -v') t.same(list[2][1], process.version, 'node -v') t.same(list[3][1], '', 'no registry, but no crash') From bb584e16434bd30a2d3b86b90eca44c106bc68b8 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 7 Oct 2019 17:30:48 -0700 Subject: [PATCH 25/27] docs: update changelog for 6.12.0 --- CHANGELOG.md | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 867221ecac2d5..4fbcb82690a90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,15 @@ ## 6.12.0 (2019-10-08): Now `npm ci` runs prepare scripts for git dependencies, and respects the -`--no-optional` argument. +`--no-optional` argument. Warnings for `engine` mismatches are printed +again. Various other fixes and cleanups. ### BUG FIXES * [`890b245dc`](https://github.com/npm/cli/commit/890b245dc1f609590d8ab993fac7cf5a37ed46a5) - [#252](https://github.com/npm/cli/pull/252) - chore(ci): add dirPacker to options + [#252](https://github.com/npm/cli/pull/252) ci: add dirPacker to options ([@claudiahdz](https://github.com/claudiahdz)) -* [`5aba50ad0`](https://github.com/npm/cli/commit/5aba50ad0889d468ecfa9d6d0446a89f70db73d5) +* [`f3299acd0`](https://github.com/npm/cli/commit/f3299acd0b4249500e940776aca77cc6c0977263) [#257](https://github.com/npm/cli/pull/257) [npm.community#4792](https://npm.community/t/engines-and-engines-strict-ignored/4792) warn message on engine mismatch @@ -19,41 +19,49 @@ Now `npm ci` runs prepare scripts for git dependencies, and respects the [npm.community#10288](https://npm.community/t/npm-token-err-figgypudding-options-cannot-be-modified-use-concat-instead/10288) Fix figgyPudding error in `npm token` ([@benblank](https://github.com/benblank)) +* [`70f54dcb5`](https://github.com/npm/cli/commit/70f54dcb5693b301c6b357922b7e8d16b57d8b00) + [#241](https://github.com/npm/cli/pull/241) doctor: Make OK more + consistent ([@gemal](https://github.com/gemal)) ### FEATURES * [`ed993a29c`](https://github.com/npm/cli/commit/ed993a29ccf923425317c433844d55dbea2f23ee) - [#249](https://github.com/npm/cli/pull/249) - Add CI environment variables to user-agent - ([@isaacs](https://github.com/isaacs)) + [#249](https://github.com/npm/cli/pull/249) Add CI environment variables + to user-agent ([@isaacs](https://github.com/isaacs)) * [`f6b0459a4`](https://github.com/npm/cli/commit/f6b0459a466a2c663dbd549cdc331e7732552dca) - [#248](https://github.com/npm/cli/pull/248) - Add option to save package-lock without formatting - Adds a new config `--format-package-lock`, which defaults to true. + [#248](https://github.com/npm/cli/pull/248) Add option to save + package-lock without formatting Adds a new config + `--format-package-lock`, which defaults to true. ([@bl00mber](https://github.com/bl00mber)) ### DEPENDENCIES * [`0ca063c5d`](https://github.com/npm/cli/commit/0ca063c5dc961c4aa17373f4b33fb54c51c8c8d6) `npm-lifecycle@3.1.4`: - - fix: filter functions and undefined out of makeEnv ([@isaacs](https://github.com/isaacs)) + - fix: filter functions and undefined out of makeEnv + ([@isaacs](https://github.com/isaacs)) * [`5df6b0ea2`](https://github.com/npm/cli/commit/5df6b0ea2e3106ba65bba649cc8d7f02f4738236) `libcipm@4.0.4`: - - fix: pack git directories properly ([@claudiahdz](https://github.com/claudiahdz)) - - respect no-optional argument ([@cruzdanilo](https://github.com/cruzdanilo)) + - fix: pack git directories properly + ([@claudiahdz](https://github.com/claudiahdz)) + - respect no-optional argument + ([@cruzdanilo](https://github.com/cruzdanilo)) * [`7e04f728c`](https://github.com/npm/cli/commit/7e04f728cc4cd4853a8fc99e2df0a12988897589) `tar@4.4.12` * [`5c380e5a3`](https://github.com/npm/cli/commit/5c380e5a33d760bb66a4285b032ae5f50af27199) - `stringify-package@1.0.1` - ([@isaacs](https://github.com/isaacs)) -* [`bee6d42c6`](https://github.com/npm/cli/commit/bee6d42c68733fb59d3698f5d80fb748901f2a60) - [#260](https://github.com/npm/cli/pull/260) - `node-gyp@5.0.4`: - ([@isaacs](https://github.com/isaacs)) + `stringify-package@1.0.1` ([@isaacs](https://github.com/isaacs)) +* [`62f2ca692`](https://github.com/npm/cli/commit/62f2ca692ac0c0467ef4cf74f91777a5175258c4) + `node-gyp@5.0.5` ([@isaacs](https://github.com/isaacs)) * [`0ff0ea47a`](https://github.com/npm/cli/commit/0ff0ea47a8840dd7d952bde7f7983a5016cda8ea) - `npm-install-checks@3.0.2` - ([@isaacs](https://github.com/isaacs)) + `npm-install-checks@3.0.2` ([@isaacs](https://github.com/isaacs)) +* [`f46edae94`](https://github.com/npm/cli/commit/f46edae9450b707650a0efab09aa1e9295a18070) + `hosted-git-info@2.8.5` ([@isaacs](https://github.com/isaacs)) + +### TESTING +* [`44a2b036b`](https://github.com/npm/cli/commit/44a2b036b34324ec85943908264b2e36de5a9435) + [#262](https://github.com/npm/cli/pull/262) fix root-ownership race + conditions in meta-test ([@isaacs](https://github.com/isaacs)) ## 6.11.3 (2019-09-03): From d86ec5df3c9dce9367623ea48fd24e1b4af0c56d Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 8 Oct 2019 08:40:30 -0700 Subject: [PATCH 26/27] update AUTHORS --- AUTHORS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AUTHORS b/AUTHORS index a6ef0eb722bf7..be910e716ee04 100644 --- a/AUTHORS +++ b/AUTHORS @@ -658,3 +658,7 @@ Sara Ahbabou Gareth Jones Ruy Adorno Michael Perrotte +Ben Blank +Christian Clauss +Nikita Lebedev +Henrik Gemal From 44ddd0b528732028ea4f38ef15b5826f3f4e2ec1 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 8 Oct 2019 08:40:30 -0700 Subject: [PATCH 27/27] 6.12.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7350b6bf7eaba..c0f1ead6f0ac5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "npm", - "version": "6.12.0-next.0", + "version": "6.12.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3a8435c64bd98..9e24f77f4b3c5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "6.12.0-next.0", + "version": "6.12.0", "name": "npm", "description": "a package manager for JavaScript", "keywords": [