What is @oclif/plugin-update?
@oclif/plugin-update is a plugin for the Oclif CLI framework that provides functionality for updating CLI applications. It allows developers to easily integrate update commands into their CLI tools, ensuring that users can always have the latest version of the tool.
What are @oclif/plugin-update's main functionalities?
Check for Updates
This feature allows the CLI tool to check for updates. The `UpdateCommand` class from `@oclif/plugin-update` is extended to create a custom update command that can be run to check for updates.
const { Command } = require('@oclif/core');
const { UpdateCommand } = require('@oclif/plugin-update');
class MyUpdateCommand extends UpdateCommand {
async run() {
await super.run();
this.log('Checked for updates!');
}
}
module.exports = MyUpdateCommand;
Run Update
This feature allows the CLI tool to perform an update. The `UpdateCommand` class is used to run the update process, ensuring that the CLI tool is updated to the latest version.
const { Command } = require('@oclif/core');
const { UpdateCommand } = require('@oclif/plugin-update');
class MyUpdateCommand extends UpdateCommand {
async run() {
await super.run();
this.log('CLI tool updated to the latest version!');
}
}
module.exports = MyUpdateCommand;
Other packages similar to @oclif/plugin-update
update-notifier
The `update-notifier` package checks for updates of a CLI tool and notifies the user if a new version is available. Unlike `@oclif/plugin-update`, it does not perform the update itself but rather informs the user to update manually.
npm-check-updates
`npm-check-updates` is a package that allows you to find and update outdated npm dependencies. While it is not specifically for CLI tools, it provides similar functionality in terms of checking for and updating dependencies.
yarn-upgrade-all
`yarn-upgrade-all` is a package that upgrades all dependencies for a project using Yarn. It is similar to `@oclif/plugin-update` in that it automates the update process, but it is focused on project dependencies rather than CLI tools.
@oclif/plugin-update
Usage
See https://oclif.io/docs/releasing.html#autoupdater
Commands
oclif-example update [CHANNEL]
update the oclif-example CLI
USAGE
$ oclif-example update [CHANNEL] [-a] [--force] [-i | -v <value>]
FLAGS
-a, --available See available versions.
-i, --interactive Interactively select version to install. This is ignored if a channel is provided.
-v, --version=<value> Install a specific version.
--force Force a re-download of the requested version.
DESCRIPTION
update the oclif-example CLI
EXAMPLES
Update to the stable channel:
$ oclif-example update stable
Update to a specific version:
$ oclif-example update --version 1.0.0
Interactively select version:
$ oclif-example update --interactive
See available versions:
$ oclif-example update --available
See code: src/commands/update.ts
Contributing
See contributing guide