Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crates-updater

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crates-updater - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# [1.1.0](https://github.com/ffflorian/crates-updater/compare/v1.0.0...v1.1.0) (2019-08-17)
### Features
- Quiet mode, simple functions ([#123](https://github.com/ffflorian/crates-updater/issues/123)) ([9e075d8](https://github.com/ffflorian/crates-updater/commit/9e075d8))
# [1.0.0](https://github.com/ffflorian/crates-updater/compare/v0.4.0...v1.0.0) (2019-07-17)

@@ -2,0 +8,0 @@

39

dist/cli.js

@@ -5,3 +5,3 @@ #!/usr/bin/env node

const program = require("commander");
const CratesUpdater_1 = require("./CratesUpdater");
const CratesUpdater = require("./CratesUpdater");
const { name, version, description } = require('../package.json');

@@ -11,24 +11,29 @@ program

.description(description)
.option('-p, --package <package>', 'which package to check (required)')
.option('-V, --package-version <version>', 'which version to check')
.arguments('<package>')
.arguments('[packageVersion]')
.option('-q, --quiet', 'quiet mode. Display newer version or nothing')
.version(version, '-v, --version')
.parse(process.argv);
if (!program.options.length || !program.package) {
if (!program.args.length) {
program.outputHelp();
process.exit(1);
}
const cratesUpdater = new CratesUpdater_1.CratesUpdater();
if (program.package && program.packageVersion) {
cratesUpdater
.checkForUpdate(program.package, program.packageVersion)
const [packageName, packageVersion] = program.args;
if (packageVersion) {
CratesUpdater.checkForUpdate(packageName, packageVersion)
.then(version => {
if (version) {
console.log(`An update for ${program.package} is available: ${version}.`);
if (program.quiet) {
if (version) {
console.log(version);
}
}
else {
console.log(`No update for ${program.package} available.`);
const text = version
? `An update for ${packageName} is available: ${version}.`
: `No update for ${packageName} available.`;
console.log(text);
}
})
.catch(error => {
console.error(error);
console.error(error.message);
process.exit(1);

@@ -38,7 +43,9 @@ });

else {
cratesUpdater
.getLatestVersion(program.package)
.then(version => console.log(version.num))
CratesUpdater.getLatestVersion(packageName)
.then(version => {
const text = program.quiet ? version.num : `Latest ${packageName} version is ${version.num}.`;
console.log(text);
})
.catch(error => {
console.error(error);
console.error(error.message);
process.exit(1);

@@ -45,0 +52,0 @@ });

import { Version as CrateVersion } from 'crates.io';
declare class CratesUpdater {
private readonly cratesIO;
constructor();
getVersions(packageName: string): Promise<CrateVersion[]>;
getLatestVersion(packageName: string): Promise<CrateVersion>;
checkForUpdate(packageName: string, version: string): Promise<string | null>;
}
export { CratesUpdater };
export declare function checkForUpdate(packageName: string, version: string): Promise<string | null>;
export declare function getLatestVersion(packageName: string): Promise<CrateVersion>;
export declare function getVersions(packageName: string): Promise<CrateVersion[]>;

@@ -13,29 +13,27 @@ "use strict";

const crates_io_1 = require("crates.io");
class CratesUpdater {
constructor() {
this.cratesIO = new crates_io_1.CratesIO();
}
getVersions(packageName) {
return __awaiter(this, void 0, void 0, function* () {
const { versions } = yield this.cratesIO.api.crates.getVersions(packageName);
return versions;
});
}
getLatestVersion(packageName) {
return __awaiter(this, void 0, void 0, function* () {
const versions = yield this.getVersions(packageName);
return versions.sort((a, b) => compareVersions(a.num, b.num)).pop();
});
}
checkForUpdate(packageName, version) {
return __awaiter(this, void 0, void 0, function* () {
const latestVersion = yield this.getLatestVersion(packageName);
if (compareVersions(latestVersion.num, version) > 0) {
return latestVersion.num;
}
return null;
});
}
const cratesIO = new crates_io_1.CratesIO();
function checkForUpdate(packageName, version) {
return __awaiter(this, void 0, void 0, function* () {
const latestVersion = yield getLatestVersion(packageName);
if (compareVersions(latestVersion.num, version) > 0) {
return latestVersion.num;
}
return null;
});
}
exports.CratesUpdater = CratesUpdater;
exports.checkForUpdate = checkForUpdate;
function getLatestVersion(packageName) {
return __awaiter(this, void 0, void 0, function* () {
const versions = yield getVersions(packageName);
return versions.sort((a, b) => compareVersions(a.num, b.num)).pop();
});
}
exports.getLatestVersion = getLatestVersion;
function getVersions(packageName) {
return __awaiter(this, void 0, void 0, function* () {
const { versions } = yield cratesIO.api.crates.getVersions(packageName);
return versions;
});
}
exports.getVersions = getVersions;
//# sourceMappingURL=CratesUpdater.js.map

@@ -8,5 +8,5 @@ {

"dependencies": {
"commander": "2.20.0",
"compare-versions": "3.5.0",
"crates.io": "0.4.1"
"commander": "3.0.0",
"compare-versions": "3.5.1",
"crates.io": "1.0.0"
},

@@ -16,11 +16,12 @@ "description": "Check your Rust packages for updates.",

"@ffflorian/prettier-config": "0.0.5",
"@ffflorian/tslint-config": "0.4.0",
"@ffflorian/tslint-config": "0.5.0",
"@semantic-release/changelog": "3.0.4",
"@semantic-release/git": "7.0.16",
"@types/node": "~12",
"husky": "3.0.0",
"lint-staged": "9.2.0",
"husky": "3.0.3",
"lint-staged": "9.2.1",
"prettier": "1.18.2",
"rimraf": "2.6.3",
"semantic-release": "15.13.18",
"rimraf": "3.0.0",
"semantic-release": "15.13.21",
"ts-node": "8.3.0",
"tslint": "5.18.0",

@@ -75,5 +76,6 @@ "tslint-config-prettier": "1.18.0",

"release": "semantic-release",
"start": "ts-node src/cli.ts",
"test": "exit 0"
},
"version": "1.0.0"
"version": "1.1.0"
}

@@ -12,3 +12,3 @@ # crates-updater [![Build Status](https://action-badges.now.sh/ffflorian/crates-updater)](https://github.com/ffflorian/crates-updater/actions/) [![npm version](https://img.shields.io/npm/v/crates-updater.svg?style=flat)](https://www.npmjs.com/package/crates-updater) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=ffflorian/crates-updater)](https://dependabot.com)

```
Usage: crates-updater [options]
Usage: crates-updater [options] <package> [packageVersion]

@@ -18,6 +18,5 @@ Check your Rust packages for updates.

Options:
-p, --package <package> which package to check (required)
-V, --package-version <version> which version to check
-v, --version output the version number
-h, --help output usage information
-q, --quiet quiet mode. Display newer version or nothing
-v, --version output the version number
-h, --help output usage information
```

@@ -29,6 +28,10 @@

# returns either a newer version or nothing
crates-updater -p ripgrep -V 0.9.0
crates-updater ripgrep -q 0.9.0
# returns the latest version
crates-updater -p ripgrep
# returns the latest version with a helpful text
crates-updater ripgrep
```
## API Usage
See [`cli.ts`](./src/cli.ts).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc