@radhirasho/latest
is a Node.js utility that checks the latest version of a given package from npm or other registries. It can be used as a CLI tool or as a library in your Node.js projects.
To install the CLI globally, use:
npm install -g @radhirasho/latest
To install the library in your project, use:
npm install @radhirasho/latest
You can use the latest
command to check the latest version of packages. For example:
latest <package-name>
You can also check multiple packages at once:
latest <package-name-1> <package-name-2> ...
You can also use the package programmatically in your Node.js projects.
import { latest, checkUpdate } from "@radhirasho/latest";
To check the latest version of a package:
const { value, error } = await latest("package-name");
if (error) {
console.error("Error fetching latest version:", error);
} else {
console.log("Latest version:", value);
}
To check if a package needs an update:
const pkg = {
name: "package-name",
version: "1.0.0"
};
const result = await checkUpdate(pkg);
console.log(result);
You can pass options to the latest
function to customize its behavior:
all
: Iftrue
, fetches all version tags.registry
: Specifies the registry to use (e.g.,npm
,yarn
).
Example:
const options = {
all: true,
registry: "yarn"
};
const { value, error } = await latest("package-name", options);
You can pass options to the checkUpdate
function to customize its behavior:
latest
: Options to pass to thelatest
function.
Example:
const options = {
latest: {
all: true,
registry: "yarn"
}
};
const result = await checkUpdate(pkg, options);
To build the project, run:
npm run build
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
See the LICENSE file for details.
Radhi Rasho
Inspired by node-latest that I ran into without realizing and noticed it was dependent on npm, which wasn't really necessary so I found a way to use fetch and have similar functionality, plus some.