Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
Command Reference

upgrade


The blocklet server upgrade command updates your Blocklet Server to the latest available version. This ensures you have the newest features, performance improvements, and security patches. The command handles the entire process automatically, from checking for updates to restarting the server after the installation is complete.

This command is part of the server command group for managing your Blocklet Server instance. For a full list of related commands, see the server commands reference.

Usage#

To run the upgrade, execute the following command in your terminal:

blocklet server upgrade

Upgrade Workflow#

The upgrade process follows a series of automated steps to ensure a safe and successful update. The workflow is illustrated below:

No

Yes

No

Yes

Yes

No

Yes

No

Start: blocklet server upgrade

Check write permissions

Print error and suggest sudo

Fetch latest version from npm

Is latest > current?

Print 'Already latest version' and exit

Is Blocklet Server running?

Stop running server

Install new version using package manager

Was server running before?

Restart server from original data directory

Print success message

End


Key Steps Explained#

  1. Permission Check: Before making any changes, the command verifies if it has sufficient permissions to write to the Blocklet CLI's installation directory. If not, it will fail with an error message, often suggesting the use of sudo.
  2. Version Check: The command contacts the npm registry to find the latest published version of @blocklet/cli and compares it with the currently installed version using semantic versioning.
  3. Graceful Shutdown: If a Blocklet Server instance is currently running, the upgrade process will automatically stop it to prevent file conflicts or data corruption during the update.
  4. Installation: The command uses your system's default JavaScript package manager (like npm or yarn) to download and install the latest version of the CLI.
  5. Automatic Restart: If the server was running before the upgrade, the command will automatically restart it from its original data directory once the installation is complete. This ensures your services come back online without manual intervention.

Example#

Here is an example of the output you would see during a typical upgrade process:

$ blocklet server upgrade
ℹ Using blocklet server from /home/user/.nvm/versions/node/v18.17.1/bin/blocklet
ℹ Checking permissions...
ℹ Current version is 3.1.0, found latest version 3.2.0
ℹ Begin upgrade
ℹ Stopping Blocklet Server ...
ℹ Installing Blocklet Server by npm install -g @blocklet/cli@latest ...

added 1 package, and audited 571 packages in 6s

86 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
ℹ Restarting Blocklet Server ...
✔ Blocklet Server started
✔ Blocklet Server upgrade success, current version is 3.2.0

If your Blocklet Server is already up-to-date, the command will inform you and exit:

$ blocklet server upgrade
ℹ The current version 3.2.0 is the latest version, no need to upgrade


After a successful upgrade, it's a good practice to verify that your server and blocklets are running correctly. You can use the blocklet server status command to check their current state.