diff options
Diffstat (limited to 'deps/npm/node_modules/pacote/node_modules/npm-pick-manifest')
5 files changed, 284 insertions, 0 deletions
diff --git a/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/CHANGELOG.md b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/CHANGELOG.md new file mode 100644 index 0000000000..8c12608083 --- /dev/null +++ b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/CHANGELOG.md @@ -0,0 +1,46 @@ +# Change Log + +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. + +<a name="1.0.3"></a> +## [1.0.3](https://github.com/zkat/npm-pick-manifest/compare/v1.0.2...v1.0.3) (2017-05-04) + + +### Bug Fixes + +* **semver:** use semver.clean() instead ([f4133b5](https://github.com/zkat/npm-pick-manifest/commit/f4133b5)) + + + +<a name="1.0.2"></a> +## [1.0.2](https://github.com/zkat/npm-pick-manifest/compare/v1.0.1...v1.0.2) (2017-05-04) + + +### Bug Fixes + +* **picker:** spaces in `wanted` prevented match ([97a7d0a](https://github.com/zkat/npm-pick-manifest/commit/97a7d0a)) + + + +<a name="1.0.1"></a> +## [1.0.1](https://github.com/zkat/npm-pick-manifest/compare/v1.0.0...v1.0.1) (2017-04-24) + + +### Bug Fixes + +* **deps:** forgot to add semver ([1876f4f](https://github.com/zkat/npm-pick-manifest/commit/1876f4f)) + + + +<a name="1.0.0"></a> +# 1.0.0 (2017-04-24) + + +### Features + +* **api:** initial implementation. ([b086912](https://github.com/zkat/npm-pick-manifest/commit/b086912)) + + +### BREAKING CHANGES + +* **api:** ex nihilo diff --git a/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/LICENSE.md b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/LICENSE.md new file mode 100644 index 0000000000..c05cb09586 --- /dev/null +++ b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/LICENSE.md @@ -0,0 +1,3 @@ +To the extent possible under law, maintainers for this project have waived all copyright and related or neighboring rights to this project. + +For more information on this waiver, see: https://creativecommons.org/publicdomain/zero/1.0/ diff --git a/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/README.md b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/README.md new file mode 100644 index 0000000000..206af2f317 --- /dev/null +++ b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/README.md @@ -0,0 +1,76 @@ +# npm-pick-manifest [![npm version](https://img.shields.io/npm/v/npm-pick-manifest.svg)](https://npm.im/npm-pick-manifest) [![license](https://img.shields.io/npm/l/npm-pick-manifest.svg)](https://npm.im/npm-pick-manifest) [![Travis](https://img.shields.io/travis/zkat/npm-pick-manifest.svg)](https://travis-ci.org/zkat/npm-pick-manifest) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/npm-pick-manifest?svg=true)](https://ci.appveyor.com/project/zkat/npm-pick-manifest) [![Coverage Status](https://coveralls.io/repos/github/zkat/npm-pick-manifest/badge.svg?branch=latest)](https://coveralls.io/github/zkat/npm-pick-manifest?branch=latest) + +[`npm-pick-manifest`](https://github.com/zkat/npm-pick-manifest) is a standalone +implementation of [npm](https://npmjs.com)'s semver range resolution algorithm. + +## Install + +`$ npm install --save npm-pick-manifest` + +## Table of Contents + +* [Example](#example) +* [Features](#features) +* [Contributing](#contributing) +* [API](#api) + * [`pickManifest()`](#pick-manifest) + +### Example + +```javascript +const pickManifest = require('npm-pick-manifest') + +fetch('https://registry.npmjs.org/npm-pick-manifest').then(res => { + return res.json() +}).then(packument => { + return pickManifest(packument, '^1.0.0') +}) // get same manifest as npm would get if you `npm i npm-pick-manifest@^1.0.0` +``` + +### Features + +* Uses npm's exact semver resolution algorithm +* Supports ranges, tags, and versions + +### Contributing + +The npm-pick-manifest team enthusiastically welcomes contributions and project participation! +There's a bunch of things you can do if you want to contribute! The [Contributor +Guide](CONTRIBUTING.md) has all the information you need for everything from +reporting bugs to contributing entire new features. Please don't hesitate to +jump in if you'd like to, or even ask us questions if something isn't clear. + +### API + +#### <a name="pick-manifest"></a> `> pickManifest(packument, selector, [opts]) -> manifest` + +Returns the manifest that matches `selector`, or throws an error. + +Packuments are anything returned by metadata URLs from the npm registry. That +is, they're objects with the following shape (only fields used by +`npm-pick-manifest` included): + +```javascript +{ + name: 'some-package', + 'dist-tags': { + foo: '1.0.1' + }, + versions: { + '1.0.0': { version: '1.0.0' }, + '1.0.1': { version: '1.0.1' }, + '1.0.2': { version: '1.0.2' }, + '2.0.0': { version: '2.0.0' } + } +} +``` + +The algorithm will follow npm's algorithm for semver resolution, and only `tag`, +`range`, and `version` selectors are supported. + +The function will throw `ETARGET` if there was no matching manifest, and +`ENOVERSIONS` if the packument object has no valid versions in `versions`. + +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. diff --git a/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/index.js b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/index.js new file mode 100644 index 0000000000..87d9a95b2b --- /dev/null +++ b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/index.js @@ -0,0 +1,75 @@ +'use strict' + +const npa = require('npm-package-arg') +const semver = require('semver') + +module.exports = pickManifest +function pickManifest (packument, wanted, opts) { + opts = opts || {} + const spec = npa.resolve(packument.name, wanted) + const type = spec.type + if (type === 'version' || type === 'range') { + wanted = semver.clean(wanted) || wanted + } + const distTags = packument['dist-tags'] || {} + const versions = Object.keys(packument.versions || {}).filter(v => semver.valid(v)) + let err + + if (!versions.length) { + err = new Error(`No valid versions available for ${packument.name}`) + err.code = 'ENOVERSIONS' + err.name = packument.name + err.type = type + err.wanted = wanted + throw err + } + + let target + + if (type === 'tag') { + target = distTags[wanted] + } else if (type === 'version') { + target = wanted + } else if (type !== 'range') { + throw new Error('Only tag, version, and range are supported') + } + + const tagVersion = distTags[opts.defaultTag || 'latest'] + + if ( + !target && + tagVersion && + packument.versions[tagVersion] && + semver.satisfies(tagVersion, wanted, true) + ) { + target = tagVersion + } + + if (!target) { + target = semver.maxSatisfying(versions, wanted, true) + } + + if (!target && wanted === '*') { + // 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 (!manifest) { + err = new Error( + `No matching version found for ${packument.name}@${wanted}` + ) + err.code = 'ETARGET' + err.name = packument.name + err.type = type + err.wanted = wanted + err.versions = versions + err.distTags = distTags + err.defaultTag = opts.defaultTag + throw err + } else { + return manifest + } +} diff --git a/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/package.json b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/package.json new file mode 100644 index 0000000000..f6793ed68d --- /dev/null +++ b/deps/npm/node_modules/pacote/node_modules/npm-pick-manifest/package.json @@ -0,0 +1,84 @@ +{ + "_from": "npm-pick-manifest@^1.0.3", + "_id": "npm-pick-manifest@1.0.3", + "_integrity": "sha512-L2UKmHEWw2RMlqZEx/0iHq1TWkSV1TiODFsmZ11Jxl2lBqL6+f2Pu4gBPsYkYIuSdgd7bALz28rgaoH1EiGHcg==", + "_location": "/pacote/npm-pick-manifest", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "npm-pick-manifest@^1.0.3", + "name": "npm-pick-manifest", + "escapedName": "npm-pick-manifest", + "rawSpec": "^1.0.3", + "saveSpec": null, + "fetchSpec": "^1.0.3" + }, + "_requiredBy": [ + "/pacote" + ], + "_resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-1.0.3.tgz", + "_shasum": "a56fed120b2d8adaec5334ddd07cf23b2389e8de", + "_shrinkwrap": null, + "_spec": "npm-pick-manifest@^1.0.3", + "_where": "/Users/zkat/Documents/code/npm/node_modules/pacote", + "author": { + "name": "Kat Marchán", + "email": "kzm@sykosomatic.org" + }, + "bin": null, + "bugs": { + "url": "https://github.com/zkat/npm-pick-manifest/issues" + }, + "bundleDependencies": false, + "config": { + "nyc": { + "exclude": [ + "node_modules/**", + "test/**" + ] + } + }, + "dependencies": { + "npm-package-arg": "^5.0.1", + "semver": "^5.3.0" + }, + "deprecated": false, + "description": "Resolves a matching manifest from a package metadata document according to standard npm semver resolution rules.", + "devDependencies": { + "nyc": "^10.2.0", + "standard": "^9.0.2", + "standard-version": "^4.0.0", + "tap": "^10.3.2", + "weallbehave": "^1.0.0", + "weallcontribute": "^1.0.8" + }, + "files": [ + "*.js" + ], + "homepage": "https://github.com/zkat/npm-pick-manifest#readme", + "keywords": [ + "npm", + "semver", + "package manager" + ], + "license": "CC0-1.0", + "main": "index.js", + "name": "npm-pick-manifest", + "optionalDependencies": {}, + "peerDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/zkat/npm-pick-manifest.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --100 --coverage 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'" + }, + "version": "1.0.3" +} |