diff --git a/node_modules/npm-pick-manifest/CHANGELOG.md b/node_modules/npm-pick-manifest/CHANGELOG.md index 5f53e8fce591f..2112665f7572e 100644 --- a/node_modules/npm-pick-manifest/CHANGELOG.md +++ b/node_modules/npm-pick-manifest/CHANGELOG.md @@ -2,6 +2,46 @@ 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.2.3](https://github.com/zkat/npm-pick-manifest/compare/v2.2.2...v2.2.3) (2018-10-31) + + +### Bug Fixes + +* **enjoyBy:** rework semantics for enjoyBy again ([5e89b62](https://github.com/zkat/npm-pick-manifest/commit/5e89b62)) + + + + +## [2.2.2](https://github.com/zkat/npm-pick-manifest/compare/v2.2.1...v2.2.2) (2018-10-31) + + +### Bug Fixes + +* **enjoyBy:** rework semantics for enjoyBy ([5684f45](https://github.com/zkat/npm-pick-manifest/commit/5684f45)) + + + + +## [2.2.1](https://github.com/zkat/npm-pick-manifest/compare/v2.2.0...v2.2.1) (2018-10-30) + + + + +# [2.2.0](https://github.com/zkat/npm-pick-manifest/compare/v2.1.0...v2.2.0) (2018-10-30) + + +### Bug Fixes + +* **audit:** npm audit fix --force ([d5ae6c4](https://github.com/zkat/npm-pick-manifest/commit/d5ae6c4)) + + +### Features + +* **enjoyBy:** add opts.enjoyBy option to filter versions by date ([0b8a790](https://github.com/zkat/npm-pick-manifest/commit/0b8a790)) + + + # [2.1.0](https://github.com/zkat/npm-pick-manifest/compare/v2.0.1...v2.1.0) (2017-10-18) diff --git a/node_modules/npm-pick-manifest/README.md b/node_modules/npm-pick-manifest/README.md index 206af2f317f82..a9a027bfcb460 100644 --- a/node_modules/npm-pick-manifest/README.md +++ b/node_modules/npm-pick-manifest/README.md @@ -74,3 +74,11 @@ The function will throw `ETARGET` if there was no matching manifest, and If `opts.defaultTag` is provided, it will be used instead of `latest`. That is, if that tag matches the selector, it will be used, even if a higher available version matches the range. + +If `opts.enjoyBy` is provided, it should be something that can be passed to `new +Date(x)`, such as a `Date` object or a timestamp string. It will be used to +filter the selected versions such that only versions less than or equal to +`enjoyBy` are considered. + +If `opts.includeDeprecated` passed in as true, deprecated versions will be +selected. By default, deprecated versions other than `defaultTag` are ignored. diff --git a/node_modules/npm-pick-manifest/index.js b/node_modules/npm-pick-manifest/index.js index 133b62723457b..d9a8373e57f14 100644 --- a/node_modules/npm-pick-manifest/index.js +++ b/node_modules/npm-pick-manifest/index.js @@ -1,19 +1,35 @@ 'use strict' +const figgyPudding = require('figgy-pudding') const npa = require('npm-package-arg') const semver = require('semver') +const PickerOpts = figgyPudding({ + defaultTag: { default: 'latest' }, + enjoyBy: {}, + includeDeprecated: { default: false } +}) + module.exports = pickManifest function pickManifest (packument, wanted, opts) { - opts = opts || {} + opts = PickerOpts(opts) + const time = opts.enjoyBy && packument.time && +(new Date(opts.enjoyBy)) const spec = npa.resolve(packument.name, wanted) const type = spec.type if (type === 'version' || type === 'range') { wanted = semver.clean(wanted, true) || wanted } const distTags = packument['dist-tags'] || {} - const versions = Object.keys(packument.versions || {}).filter(v => semver.valid(v, true)) - const undeprecated = versions.filter(v => !packument.versions[v].deprecated) + const versions = Object.keys(packument.versions || {}).filter(v => { + return semver.valid(v, true) + }) + + function enjoyableBy (v) { + return !time || ( + packument.time[v] && time >= +(new Date(packument.time[v])) + ) + } + let err if (!versions.length) { @@ -27,43 +43,69 @@ function pickManifest (packument, wanted, opts) { let target - if (type === 'tag') { + if (type === 'tag' && enjoyableBy(distTags[wanted])) { target = distTags[wanted] } else if (type === 'version') { target = wanted - } else if (type !== 'range') { + } else if (type !== 'range' && enjoyableBy(distTags[wanted])) { throw new Error('Only tag, version, and range are supported') } - const tagVersion = distTags[opts.defaultTag || 'latest'] + const tagVersion = distTags[opts.defaultTag] if ( !target && tagVersion && packument.versions[tagVersion] && + enjoyableBy(tagVersion) && semver.satisfies(tagVersion, wanted, true) ) { target = tagVersion } if (!target && !opts.includeDeprecated) { + const undeprecated = versions.filter(v => !packument.versions[v].deprecated && enjoyableBy(v) + ) target = semver.maxSatisfying(undeprecated, wanted, true) } if (!target) { - target = semver.maxSatisfying(versions, wanted, true) + const stillFresh = versions.filter(enjoyableBy) + target = semver.maxSatisfying(stillFresh, wanted, true) } - if (!target && wanted === '*') { + if (!target && wanted === '*' && enjoyableBy(tagVersion)) { // This specific corner is meant for the case where // someone is using `*` as a selector, but all versions // are pre-releases, which don't match ranges at all. target = tagVersion } - const manifest = target && packument.versions[target] + if ( + !target && + time && + type === 'tag' && + distTags[wanted] && + !enjoyableBy(distTags[wanted]) + ) { + const stillFresh = versions.filter(v => + enjoyableBy(v) && semver.lte(v, distTags[wanted], true) + ).sort(semver.rcompare) + target = stillFresh[0] + } + + const manifest = ( + target && + packument.versions[target] + ) if (!manifest) { err = new Error( - `No matching version found for ${packument.name}@${wanted}` + `No matching version found for ${packument.name}@${wanted}${ + opts.enjoyBy + ? ` with an Enjoy By date of ${ + new Date(opts.enjoyBy).toLocaleString() + }. Maybe try a different date?` + : '' + }` ) err.code = 'ETARGET' err.name = packument.name diff --git a/node_modules/npm-pick-manifest/package.json b/node_modules/npm-pick-manifest/package.json index 4cf8bf1a13c6c..a80c76d372d01 100644 --- a/node_modules/npm-pick-manifest/package.json +++ b/node_modules/npm-pick-manifest/package.json @@ -1,33 +1,28 @@ { - "_args": [ - [ - "npm-pick-manifest@2.1.0", - "/Users/rebecca/code/npm" - ] - ], - "_from": "npm-pick-manifest@2.1.0", - "_id": "npm-pick-manifest@2.1.0", + "_from": "npm-pick-manifest@2.2.3", + "_id": "npm-pick-manifest@2.2.3", "_inBundle": false, - "_integrity": "sha512-q9zLP8cTr8xKPmMZN3naxp1k/NxVFsjxN6uWuO1tiw9gxg7wZWQ/b5UTfzD0ANw2q1lQxdLKTeCCksq+bPSgbQ==", + "_integrity": "sha512-+IluBC5K201+gRU85vFlUwX3PFShZAbAgDNp2ewJdWMVSppdo/Zih0ul2Ecky/X7b51J7LrrUAP+XOmOCvYZqA==", "_location": "/npm-pick-manifest", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "npm-pick-manifest@2.1.0", + "raw": "npm-pick-manifest@2.2.3", "name": "npm-pick-manifest", "escapedName": "npm-pick-manifest", - "rawSpec": "2.1.0", + "rawSpec": "2.2.3", "saveSpec": null, - "fetchSpec": "2.1.0" + "fetchSpec": "2.2.3" }, "_requiredBy": [ - "/", - "/pacote" + "#USER", + "/" ], - "_resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-2.1.0.tgz", - "_spec": "2.1.0", - "_where": "/Users/rebecca/code/npm", + "_resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-2.2.3.tgz", + "_shasum": "32111d2a9562638bb2c8f2bf27f7f3092c8fae40", + "_spec": "npm-pick-manifest@2.2.3", + "_where": "/Users/aeschright/code/cli", "author": { "name": "Kat Marchán", "email": "kzm@sykosomatic.org" @@ -35,6 +30,7 @@ "bugs": { "url": "https://github.com/zkat/npm-pick-manifest/issues" }, + "bundleDependencies": false, "config": { "nyc": { "exclude": [ @@ -44,15 +40,17 @@ } }, "dependencies": { + "figgy-pudding": "^3.5.1", "npm-package-arg": "^6.0.0", "semver": "^5.4.1" }, + "deprecated": false, "description": "Resolves a matching manifest from a package metadata document according to standard npm semver resolution rules.", "devDependencies": { - "nyc": "^11.2.1", + "nyc": "^13.1.0", "standard": "^10.0.3", - "standard-version": "^4.2.0", - "tap": "^10.7.0", + "standard-version": "^4.4.0", + "tap": "^12.0.1", "weallbehave": "^1.2.0", "weallcontribute": "^1.0.8" }, @@ -81,5 +79,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": "2.1.0" + "version": "2.2.3" } diff --git a/package-lock.json b/package-lock.json index 398874a461afd..bd1044eb5e6a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3140,10 +3140,11 @@ } }, "npm-pick-manifest": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-2.1.0.tgz", - "integrity": "sha512-q9zLP8cTr8xKPmMZN3naxp1k/NxVFsjxN6uWuO1tiw9gxg7wZWQ/b5UTfzD0ANw2q1lQxdLKTeCCksq+bPSgbQ==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-2.2.3.tgz", + "integrity": "sha512-+IluBC5K201+gRU85vFlUwX3PFShZAbAgDNp2ewJdWMVSppdo/Zih0ul2Ecky/X7b51J7LrrUAP+XOmOCvYZqA==", "requires": { + "figgy-pudding": "^3.5.1", "npm-package-arg": "^6.0.0", "semver": "^5.4.1" } diff --git a/package.json b/package.json index f548c22a80bbb..b9f15bfe1c394 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "npm-lifecycle": "^2.1.0", "npm-package-arg": "^6.1.0", "npm-packlist": "^1.2.0", - "npm-pick-manifest": "^2.1.0", + "npm-pick-manifest": "^2.2.3", "npm-registry-fetch": "^3.8.0", "npm-user-validate": "~1.0.0", "npmlog": "~4.1.2",