|
| 1 | +// Type definitions for npm-package-arg 5.1.2 |
| 2 | +// Project: https://github.com/npm/npm-package-arg |
| 3 | +// Definitions by: pgonzal |
| 4 | + |
| 5 | +declare module 'npm-package-arg' { |
| 6 | + namespace npmPackageArg { |
| 7 | + interface IResult { |
| 8 | + /** |
| 9 | + * Indicates the type of dependency reference. For example 'version' indicates |
| 10 | + * a normal SemVer pattern. See the package README.md for full docs. |
| 11 | + * |
| 12 | + * git - a git repository |
| 13 | + * tag - a tagged version, e.g. "example@latest" |
| 14 | + * version - A specific version number, e.g. "example@1.2.3" |
| 15 | + * range - A version range, e.g. "example@2.x" |
| 16 | + * file - A local .tar.gz, .tar or .tgz file |
| 17 | + * directory - A local directory |
| 18 | + * remote - An HTTP url to a .tar.gz, .tar or .tgz file |
| 19 | + */ |
| 20 | + type: 'git' | 'tag' | 'version' | 'range' | 'file' | 'directory' | 'remote'; |
| 21 | + |
| 22 | + /** |
| 23 | + * True for tag, version and range types. |
| 24 | + */ |
| 25 | + registry: boolean | undefined; |
| 26 | + |
| 27 | + /** |
| 28 | + * If known, the "name" field expected in the package. |
| 29 | + */ |
| 30 | + name: string | null; |
| 31 | + |
| 32 | + /** |
| 33 | + * For scoped NPM packages, the scope name; otherwise the value will be null. |
| 34 | + */ |
| 35 | + scope: string | null | undefined; |
| 36 | + |
| 37 | + /** |
| 38 | + * An escaped name for use when making requests to the NPM registry. |
| 39 | + */ |
| 40 | + escapedName: string | null; |
| 41 | + |
| 42 | + /** |
| 43 | + * The original specifier passed to npmPackageArg.resolve(), or the specifier part of the |
| 44 | + * argument for npmPackageArg(). |
| 45 | + */ |
| 46 | + rawSpec: string; |
| 47 | + |
| 48 | + /** |
| 49 | + * The specifier, as normalized by NPM for saving in a package.json file. |
| 50 | + */ |
| 51 | + saveSpec: string | null; |
| 52 | + |
| 53 | + /** |
| 54 | + * The specifier, as normalized by NPM for fetching a resource. For example, a "directory" |
| 55 | + * type dependency, this will be the folder path. |
| 56 | + */ |
| 57 | + fetchSpec: string | null; |
| 58 | + |
| 59 | + /** |
| 60 | + * For Git dependencies, if the committish includes a "semver:" prefix, then this is |
| 61 | + * the range part. |
| 62 | + * Example: For "mochajs/mocha#semver:1.2.3", the value would be "1.2.3" |
| 63 | + */ |
| 64 | + gitRange: string | null | undefined; |
| 65 | + |
| 66 | + /** |
| 67 | + * For Git dependencies, the committish part of the specifier, or "master" if omitted. |
| 68 | + * Example: For "mochajs/mocha#4727d357ea", the value would be "4727d357ea" |
| 69 | + */ |
| 70 | + gitCommittish: string | null | undefined; |
| 71 | + |
| 72 | + /** |
| 73 | + * The original input that was provided. For npmPackageArg.resolve(), the name and |
| 74 | + * spec parameters will be combined, e.g. "example" and "1.2" will be combined as "example@1.2". |
| 75 | + */ |
| 76 | + raw: string; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Parses a package dependency, based on a package name and version specifier as might appear |
| 81 | + * in a package.json file. An Error object will be thrown if the input is invalid. |
| 82 | + * |
| 83 | + * @param name - The name of an NPM package, possibly including a scope |
| 84 | + * @param spec - A version specifier, e.g. "^1.2.3", "git://github.com/user/project.git#commit-ish", etc. |
| 85 | + * @param where - a path that file paths will be resolved relative to; otherwise, process.cwd() |
| 86 | + * is used |
| 87 | + * @returns an object containing parsed information. |
| 88 | + * |
| 89 | + * @see {@link https://docs.npmjs.com/files/package.json#dependencies} for full syntax. |
| 90 | + */ |
| 91 | + function resolve(name: string, spec: string, where?: string): npmPackageArg.IResult; |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Parses a package dependency, based on a combined package name and version specifier |
| 96 | + * as might be passed to "npm install". An Error object will be thrown if the input is invalid. |
| 97 | + * |
| 98 | + * @param arg - a string such as "example@1.2", "bitbucket:user/example", "file:../example", etc. |
| 99 | + * @param where - a path that file paths will be resolved relative to; otherwise, process.cwd() |
| 100 | + * is used |
| 101 | + * @returns an object containing parsed information. |
| 102 | + * |
| 103 | + * @see {@link https://docs.npmjs.com/files/package.json#dependencies} for full syntax. |
| 104 | + */ |
| 105 | + function npmPackageArg(arg: string, where?: string): npmPackageArg.IResult; |
| 106 | + |
| 107 | + export = npmPackageArg; |
| 108 | +} |
0 commit comments