Upgrade Server
The blocklet server upgrade
command provides a straightforward way to update your Blocklet Server CLI to the latest version. It automates the entire process, from checking for new versions to installing the update and restarting your server if necessary.
Usage#
To begin the upgrade process, simply run the following command:
blocklet server upgrade
The command requires no additional arguments and will handle the update procedure automatically.
The Upgrade Process#
The command follows a specific sequence to ensure a safe and successful update. Here is a breakdown of the steps involved:
Key Steps:
- Version Check: Compares your currently installed version against the latest version available on the npm registry.
- Permission Check: Verifies that it has the necessary permissions to write to the CLI's installation directory.
- Server State: Detects if a Blocklet Server instance is running. If so, it stops it gracefully before the upgrade and restarts it afterward.
- Installation: Uses your system's package manager (e.g.,
npm
) to download and install the new version globally. - Restart: If the server was running before the upgrade, it is automatically restarted to ensure service continuity.
Example Output#
When you run the command, you will see output similar to the following, keeping you informed at each step:
$ blocklet server upgrade
ℹ Using blocklet server from /home/user/.nvm/versions/node/v18.18.0/bin/blocklet
ℹ Checking permissions...
ℹ Current version is 1.16.29, found latest version 1.16.30
ℹ Begin upgrade
ℹ Stopping Blocklet Server ...
ℹ Installing Blocklet Server by npm install -g @blocklet/cli ...
added 1 package, and audited 516 packages in 3s
81 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
ℹ Restarting Blocklet Server ...
✔ Blocklet Server upgrade success, current version is 1.16.30
Handling Permission Errors#
If the CLI was installed in a directory that your current user does not have write access to, the upgrade will fail with a permission error. This is common if the CLI was initially installed using sudo
.
In this case, run the upgrade command with sudo
to provide the necessary permissions.
sudo blocklet server upgrade
This ensures the process has the required access rights to modify the installation files.