pax_global_header00006660000000000000000000000064134512743250014520gustar00rootroot0000000000000052 comment=9d0f0b115870a11372f0382e24c5658a6bf1da3a latest-version-5.1.0/000077500000000000000000000000001345127432500145025ustar00rootroot00000000000000latest-version-5.1.0/.editorconfig000066400000000000000000000002571345127432500171630ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 latest-version-5.1.0/.gitattributes000066400000000000000000000000231345127432500173700ustar00rootroot00000000000000* text=auto eol=lf latest-version-5.1.0/.gitignore000066400000000000000000000000271345127432500164710ustar00rootroot00000000000000node_modules yarn.lock latest-version-5.1.0/.npmrc000066400000000000000000000000231345127432500156150ustar00rootroot00000000000000package-lock=false latest-version-5.1.0/.travis.yml000066400000000000000000000000541345127432500166120ustar00rootroot00000000000000language: node_js node_js: - '10' - '8' latest-version-5.1.0/index.d.ts000066400000000000000000000017251345127432500164100ustar00rootroot00000000000000declare namespace latestVersion { interface Options { /** A semver range or [dist-tag](https://docs.npmjs.com/cli/dist-tag). */ readonly version?: string; } } declare const latestVersion: { /** Get the latest version of an npm package. @example ``` import latestVersion = require('latest-version'); (async () => { console.log(await latestVersion('ava')); //=> '0.18.0' console.log(await latestVersion('@sindresorhus/df')); //=> '1.0.1' // Also works with semver ranges and dist-tags console.log(await latestVersion('npm', {version: 'latest-5'})); //=> '5.5.1' })(); ``` */ (packageName: string, options?: latestVersion.Options): Promise; // TODO: Remove this for the next major release, refactor the whole definition to: // declare function latestVersion( // packageName: string, // options?: latestVersion.Options // ): Promise; // export = latestVersion; default: typeof latestVersion; }; export = latestVersion; latest-version-5.1.0/index.js000066400000000000000000000005161345127432500161510ustar00rootroot00000000000000'use strict'; const packageJson = require('package-json'); const lastestVersion = async (packageName, options) => { const {version} = await packageJson(packageName.toLowerCase(), options); return version; }; module.exports = lastestVersion; // TODO: Remove this for the next major release module.exports.default = lastestVersion; latest-version-5.1.0/index.test-d.ts000066400000000000000000000003031345127432500173540ustar00rootroot00000000000000import {expectType} from 'tsd'; import latestVersion = require('.'); expectType>(latestVersion('ava')); expectType>(latestVersion('npm', {version: 'latest-5'})); latest-version-5.1.0/license000066400000000000000000000021251345127432500160470ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (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. latest-version-5.1.0/package.json000066400000000000000000000013061345127432500167700ustar00rootroot00000000000000{ "name": "latest-version", "version": "5.1.0", "description": "Get the latest version of an npm package", "license": "MIT", "repository": "sindresorhus/latest-version", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "latest", "version", "npm", "pkg", "package", "package.json", "current", "module" ], "dependencies": { "package-json": "^6.3.0" }, "devDependencies": { "ava": "^1.4.1", "semver": "^6.0.0", "semver-regex": "^2.0.0", "tsd": "^0.7.2", "xo": "^0.24.0" } } latest-version-5.1.0/readme.md000066400000000000000000000022061345127432500162610ustar00rootroot00000000000000# latest-version [![Build Status](https://travis-ci.org/sindresorhus/latest-version.svg?branch=master)](https://travis-ci.org/sindresorhus/latest-version) > Get the latest version of an npm package Fetches the version directly from the registry instead of depending on the massive [npm](https://github.com/npm/npm/blob/8b5e7b6ae5b4cd2d7d62eaf93b1428638b387072/package.json#L37-L85) module like the [latest](https://github.com/bahamas10/node-latest) module does. ## Install ``` $ npm install latest-version ``` ## Usage ```js const latestVersion = require('latest-version'); (async () => { console.log(await latestVersion('ava')); //=> '0.18.0' console.log(await latestVersion('@sindresorhus/df')); //=> '1.0.1' // Also works with semver ranges and dist-tags console.log(await latestVersion('npm', {version: 'latest-5'})); //=> '5.5.1' })(); ``` ## Related - [latest-version-cli](https://github.com/sindresorhus/latest-version-cli) - CLI for this module - [package-json](https://github.com/sindresorhus/package-json) - Get the package.json of a package from the npm registry ## License MIT © [Sindre Sorhus](https://sindresorhus.com) latest-version-5.1.0/test.js000066400000000000000000000011451345127432500160200ustar00rootroot00000000000000import test from 'ava'; import semver from 'semver'; import semverRegex from 'semver-regex'; import latestVersion from '.'; test('latest version', async t => { t.regex(await latestVersion('ava'), semverRegex()); }); test('latest version with version', async t => { t.true(semver.satisfies(await latestVersion('package-json', {version: '0'}), '0.x')); }); test('latest version with dist-tag', async t => { t.true(semver.satisfies(await latestVersion('npm', {version: 'latest-5'}), '5.x')); }); test('latest version scoped', async t => { t.regex(await latestVersion('@sindresorhus/df'), semverRegex()); });