How to use latest-version - 10 common examples

To help you get started, we’ve selected a few latest-version examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github segmentio / typewriter / src / cli / commands / version.tsx View on Github external
async function effect() {
			try {
				let options: latest.Options = {}

				// If the user is on a pre-release, check if there's a new pre-release.
				// Otherwise, only compare against stable versions.
				const prerelease = semver.prerelease(typewriterVersion)
				if (prerelease && prerelease.length > 0) {
					options = { version: 'next' }
				}

				const latestVersion = await latest('typewriter', options)
				setLatestVersion(latestVersion)
			} catch (error) {
				// If we can't access NPM, then ignore this version check.
				handleError(error)
			}
			setIsLoading(false)
			exit()
		}
github sourcegraph / sourcegraph / browser / scripts / publish-npm.ts View on Github external
async function main(): Promise {
    const name = '@sourcegraph/code-host-integration'
    // Bump version
    let version: string
    try {
        const currentVersion = await latestVersion(name)
        signale.info(`Current version is ${currentVersion}`)
        version = semver.inc(currentVersion, 'patch')!
    } catch (err) {
        if (err && err.name === 'PackageNotFoundError') {
            signale.info('Package is not released yet')
            version = '0.0.0'
        } else {
            throw err
        }
    }
    const packageJson = {
        name,
        version,
        license: 'Apache-2.0',
        repository: {
            type: 'git',
github jovotech / jovo-cli / jovo-cli / utils / Utils.ts View on Github external
export async function getPackageVersionsNpm(packageRegex: RegExp): Promise {
	const packages = await getPackages(packageRegex);

	// Start directly with querying the data in parallel
	const queryPromises: {
		[key: string]: Promise;
	} = {};
	for (const packageName of Object.keys(packages)) {
		queryPromises[packageName] = latestVersion(packageName);
	}

	// Wait till data is available and combine data
	const returnPackages: PackageVersionsNpm = {};
	for (const packageName of Object.keys(packages)) {
		returnPackages[packageName] = {
			local: packages[packageName],
			npm: await queryPromises[packageName],
		};
	}

	return returnPackages;
}
github namics / frontend-defaults / platform / core / src / utils / version.ts View on Github external
export async function checkDependencyUpdate(
	cwd: string = process.cwd(),
	dependency: string
): Promise<{
	current?: string;
	latest?: string;
	upgradable: boolean;
}> {
	try {
		const installedVersion = await getInstalledDependencyVersion(cwd, dependency);
		const availableLatestVersion = await latestVersion(dependency);

		if (installedVersion) {
			const hasNewVersion = semver.lt(installedVersion, availableLatestVersion);
			return {
				current: installedVersion,
				latest: availableLatestVersion,
				upgradable: hasNewVersion,
			};
		}

		return {
			upgradable: false,
		};
	} catch (err) {
		// don't require an update if a failure happens
		// within latestVersion or getting installed version
github VladimirIvanin / insales-uploader / lib / cli / packageVersion.js View on Github external
return new Promise((resolve, reject) => {
    if (pkg && pkg.name !== 'insales-uploader') {
      resolve();
      return;
    }

    latestVersion('insales-uploader').then(version => {
      let pkgDiff = compareVersions(version, pkg.version);
      if (pkgDiff <= 0) {
        resolve();
      }else{
        console.log( log_edit('Внимание! Доступна новая версия insales-uploader ') + `=> ${version}`);
        console.log( log_notice('Список изменений доступен по ссылке: ') + 'https://github.com/VladimirIvanin/insales-uploader/blob/master/CHANGELOG.md' );
        resolve();
      }
    }).catch(() => {
      resolve();
    });
  });
};
github workshopper / workshopper-adventure / lib / commands / update.js View on Github external
function getVersions (shop, callback) {
  var path = require('path')
  var pkgFile = path.resolve(shop.options.appDir, 'package.json')
  try {
    var pkg = require(pkgFile)
  } catch (e) {
    return callback(e)
  }
  require('latest-version')(pkg.name).then(function (latestVersion) {
    exports.info = {
      version: latestVersion
    }
    callback(null, pkg.name, pkg.version, latestVersion)
  }).catch(function (err) {
    console.log(err)
    callback(err)
  })
}
exports.filter = function (shop) {
github namics / frontend-defaults / platform / core / src / utils / version.ts View on Github external
export async function getDependencyInstallation(cwd: string, dependency: string): Promise {
	const installed = await getInstalledDependencyVersion(cwd, dependency) || null;
	const pkg = await getPackageJSON(cwd);
	const declared = {
		dev: pkg.devDependencies![dependency],
		prod: pkg.dependencies![dependency]
	};
	const latest = await latestVersion(dependency);

	return {
		location: declared.dev ? 'devDependencies' : declared.prod ? 'dependencies' : null,
		declared: declared.dev || declared.prod || null,
		installed,
		latest,
	};
}
github ArkEcosystem / core / packages / core / src / helpers / update.ts View on Github external
const getLatestVersion = async (name: string, channel: string): Promise => {
    try {
        const version = await latestVersion(name, { version: channel });

        return version;
    } catch (error) {
        return undefined;
    }
};
github alibaba / ice / tools / iceworks / renderer / src / pages / Home / ProjectPanel / AddPackage.jsx View on Github external
    const getLatestVersion = existDeps.map((dep) => latestVersion(dep, { registryUrl }).then((v) => Promise.resolve({ name: dep, version: v })
    )
    );
github namics / frontend-defaults / platform / core / src / utils / version.ts View on Github external
export async function getLatestLTSVersion(dependency: string): Promise {
	return await latestVersion(dependency, {
		version: 'lts'
	});
}

latest-version

Get the latest version of an npm package

MIT
Latest version published 9 months ago

Package Health Score

74 / 100
Full package analysis

Popular latest-version functions