Template Upload
This commit is contained in:
54
node_modules/package-json/index.js
generated
vendored
Normal file
54
node_modules/package-json/index.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
var url = require('url');
|
||||
var got = require('got');
|
||||
var registryUrl = require('registry-url');
|
||||
var registryAuthToken = require('registry-auth-token');
|
||||
var semver = require('semver');
|
||||
|
||||
module.exports = function (name, version) {
|
||||
var scope = name.split('/')[0];
|
||||
var regUrl = registryUrl(scope);
|
||||
var pkgUrl = url.resolve(regUrl, encodeURIComponent(name).replace(/^%40/, '@'));
|
||||
var authInfo = registryAuthToken(regUrl);
|
||||
var headers = {};
|
||||
|
||||
if (authInfo) {
|
||||
headers.authorization = authInfo.type + ' ' + authInfo.token;
|
||||
}
|
||||
|
||||
return got(pkgUrl, {
|
||||
json: true,
|
||||
headers: headers
|
||||
})
|
||||
.then(function (res) {
|
||||
var data = res.body;
|
||||
|
||||
if (version === 'latest') {
|
||||
data = data.versions[data['dist-tags'].latest];
|
||||
} else if (version) {
|
||||
if (!data.versions[version]) {
|
||||
var versions = Object.keys(data.versions);
|
||||
version = semver.maxSatisfying(versions, version);
|
||||
|
||||
if (!version) {
|
||||
throw new Error('Version doesn\'t exist');
|
||||
}
|
||||
}
|
||||
|
||||
data = data.versions[version];
|
||||
|
||||
if (!data) {
|
||||
throw new Error('Version doesn\'t exist');
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
})
|
||||
.catch(function (err) {
|
||||
if (err.statusCode === 404) {
|
||||
throw new Error('Package `' + name + '` doesn\'t exist');
|
||||
}
|
||||
|
||||
throw err;
|
||||
});
|
||||
};
|
21
node_modules/package-json/license
generated
vendored
Normal file
21
node_modules/package-json/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
101
node_modules/package-json/package.json
generated
vendored
Normal file
101
node_modules/package-json/package.json
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"package-json@^2.0.0",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\latest-version"
|
||||
]
|
||||
],
|
||||
"_from": "package-json@>=2.0.0-0 <3.0.0-0",
|
||||
"_id": "package-json@2.4.0",
|
||||
"_inCache": true,
|
||||
"_location": "/package-json",
|
||||
"_nodeVersion": "4.5.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/package-json-2.4.0.tgz_1472158723527_0.22724637226201594"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"name": "sindresorhus"
|
||||
},
|
||||
"_npmVersion": "2.15.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "package-json",
|
||||
"raw": "package-json@^2.0.0",
|
||||
"rawSpec": "^2.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=2.0.0-0 <3.0.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/latest-version"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/package-json/-/package-json-2.4.0.tgz",
|
||||
"_shasum": "0d15bd67d1cbbddbb2ca222ff2edb86bcb31a8bb",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "package-json@^2.0.0",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\latest-version",
|
||||
"author": {
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"name": "Sindre Sorhus",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/package-json/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"got": "^5.0.0",
|
||||
"registry-auth-token": "^3.0.1",
|
||||
"registry-url": "^3.0.3",
|
||||
"semver": "^5.1.0"
|
||||
},
|
||||
"description": "Get the package.json of a package from the npm registry",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"mock-private-registry": "^1.1.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "0d15bd67d1cbbddbb2ca222ff2edb86bcb31a8bb",
|
||||
"tarball": "https://registry.npmjs.org/package-json/-/package-json-2.4.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "2e77257cec7604cf18d979b1d5c4baa46928d24d",
|
||||
"homepage": "https://github.com/sindresorhus/package-json#readme",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"json",
|
||||
"module",
|
||||
"npm",
|
||||
"package",
|
||||
"package.json",
|
||||
"pkg",
|
||||
"registry",
|
||||
"scope",
|
||||
"scoped"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "package-json",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/package-json.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "2.4.0"
|
||||
}
|
63
node_modules/package-json/readme.md
generated
vendored
Normal file
63
node_modules/package-json/readme.md
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# package-json [](https://travis-ci.org/sindresorhus/package-json)
|
||||
|
||||
> Get the package.json of a package from the npm registry
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save package-json
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const packageJson = require('package-json');
|
||||
|
||||
packageJson('pageres', 'latest').then(json => {
|
||||
console.log(json);
|
||||
//=> {name: 'pageres', ...}
|
||||
});
|
||||
|
||||
// also works with scoped packages
|
||||
packageJson('@company/package', 'latest').then(json => {
|
||||
console.log(json);
|
||||
//=> {name: 'package', ...}
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### packageJson(name, [version])
|
||||
|
||||
You can optionally specify a version (e.g. `1.0.0`) or `latest`.
|
||||
If you don't specify a version you'll get the [main entry](http://registry.npmjs.org/pageres/) containing all versions.
|
||||
|
||||
The version can also be in any format supported by the [semver](https://www.npmjs.com/package/semver) module. For example:
|
||||
|
||||
- `1` - get the latest `1.x.x`
|
||||
- `1.2` - get the latest `1.2.x`
|
||||
- `^1.2.3` - get the latest `1.x.x` but at least `1.2.3`
|
||||
- `~1.2.3` - get the latest `1.2.x` but at least `1.2.3`
|
||||
|
||||
|
||||
## Authentication
|
||||
|
||||
Both public and private registries are supported, for both scoped and unscoped packages, as long as the registry uses either bearer tokens or basic authentication.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [package-json-cli](https://github.com/sindresorhus/package-json-cli) - CLI for this module
|
||||
- [latest-version](https://github.com/sindresorhus/latest-version) - Get the latest version of an npm package
|
||||
- [pkg-versions](https://github.com/sindresorhus/pkg-versions) - Get the version numbers of a package from the npm registry
|
||||
- [npm-keyword](https://github.com/sindresorhus/npm-keyword) - Get a list of npm packages with a certain keyword
|
||||
- [npm-user](https://github.com/sindresorhus/npm-user) - Get user info of an npm user
|
||||
- [npm-email](https://github.com/sindresorhus/npm-email) - Get the email of an npm user
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
Reference in New Issue
Block a user