目录

ohpm update

Updates a third-party library.

Command Format

ohpm update [options] [[<@group>/]<pkg>] ...
alias: up
  • @group: namespace of the third-party library. This parameter is optional.
  • pkg: name of the third-party library. This parameter is optional.

Description

This command is used to update a locally installed third-party library to its latest version based on the semver specifications and dependency version. If pkg is not specified, the dependencies of the current project will be fully updated and the missing third-party libraries will be installed together.

Options

[h2]install_all

You can append the --all or --install_all parameter to the ohpm update command. This ensures that after the specified dependencies of the current module are successfully updated, the dependencies of all modules in the current project are installed.

In ohpm 26.0.0.630 and later versions, if installation is not required, append --no-install_all to the command.

[h2]prefix

You can append the --prefix <string> parameter to the ohpm update command to specify the root directory of the package. The root directory must contain the oh-package.json5 file.

[h2]fetch_timeout

You can append the --ft <number> or --fetch_timeout <number> parameter to the ohpm update command to set the operation timeout. If the parameter is not set, the default timeout is 60000 ms.

[h2]max_concurrent

You can append the --mc <number> or --max_concurrent <number> parameter to the ohpm update command to set the maximum number of concurrent requests (that is, the maximum number of network requests at any time during the ohpm operation). If the parameter is not set, the maximum number of concurrent requests is 50 by default.

[h2]retry_times

You can append the --rt <number> or --retry_times <number> parameter to the ohpm update command to set the maximum number of retries before an operation fails. If the parameter is not set, the maximum number of retries is 1 by default.

[h2]retry_interval

You can append the --ri <number> or --retry_interval <number> parameter to the ohpm update command to set the retry interval. If the parameter is not set, the default retry interval is 1000 ms.

[h2]strict_ssl

If no parameter is appended to the ohpm update command, or the --strict_ssl or --strict_ssl true parameter is appended, HTTPS certificate verification is enabled.

In ohpm 26.0.0.630 and later versions, to disable verification, append --no-strict_ssl (recommended) or --strict_ssl false to the command.

[h2]registry

You can append the --registry <registry> parameter to the ohpm update command to specify a repository address. If the parameter is not set, the repository address is obtained from the configuration by default.

[h2]all-modules

You can append the --all-modules parameter to the ohpm update command to update the dependencies of all modules.

[h2]tag-filter

You can append the --tag-filter <regex> parameter to the ohpm update command to update only the dependencies whose tags match the specified regular expression. Use the --tag-filter parameter to update the dependencies of all modules by default.

[h2]experimental-concurrently-safe

You can append the --experimental-concurrently-safe parameter to the ohpm update command to update dependencies concurrently and securely. This is an experimental parameter. To disable concurrent dependency installation, append --no-experimental-concurrently-safe to the command.

[h2]log_level

In ohpm 6.0.2.636 and later versions, you can append the --log_level <string> parameter to the ohpm update command to specify the log level (info, debug, warn, or error) for execution of the current command. If this parameter is not set, the log_level setting in the .ohpmrc file is applied.

[h2]debug

In ohpm 6.0.2.636 and later versions, you can append the --debug parameter to the command to set the log level to debug for execution of the current command. This configuration takes effect only on the current command line and does not alter the log level configured in the .ohpmrc file. If this parameter is not set, the log_level setting in the .ohpmrc file is applied.

[h2]lockfile_stable_order

In ohpm 6.0.2.636 and later versions, you can append the --lockfile_stable_order parameter to the ohpm update command. This ensures that if the oh-package.json5 file is not changed, the fields in the generated oh-package-lock.json5 file remain unchanged.

[h2]odm_r2_project_root

In ohpm 6.0.2.636 and later versions, you can append the --odm_r2_project_root parameter to the ohpm update command. This ensures that if the overrideDependencyMap configuration exists and the target configuration file contains dependencies configured with relative paths, ohpm will resolve and locate these relative paths based on the project root path. For details, see odm_r2_project_root.

[h2]resolve_conflict_strict

In ohpm 6.0.2.636 and later versions, you can append the --resolve_conflict_strict parameter to the ohpm update command to enable the strict mode for handling dependency version conflicts. For details, see resolve_conflict_strict.

[h2]resolve_conflict

In ohpm 6.0.2.636 and later versions, you can append the --resolve_conflict parameter to the ohpm update command to have ohpm automatically resolve dependency version conflicts. For details, see resolve_conflict.

In ohpm 26.0.0.630 and later versions, if automatic conflict resolution is not required, append --no-resolve_conflict to the command.

[h2]cache

In ohpm 6.0.2.636 and later versions, you can append the --cache <string> parameter to the ohpm update command to specify the cache path.

Example

If the current third-party library is an app and its dependency is dep1 ( dep2,...), the released versions of dep1 are as follows:

{
  "dist-tags": { "latest": "1.2.2", "release": "1.2.0" },
  "versions": [
    "1.2.2",
    "1.2.1",
    "1.2.0",
    "1.1.2",
    "1.1.1",
    "1.0.0",
    "0.4.1",
    "0.4.0",
    "0.2.0"
  ]
}

[h2]^ Dependency

Using the ^ symbol will update y and z in version x.y.z to their latest versions. Assume that the version number of dep1 in the oh-package.json5 file of the app is as follows:

"dependencies": {
  "dep1": "^1.1.1"
}

As the latest version is 1.2.2, running the ohpm update command will update the version to dep1@1.2.2.

[h2]~ Dependency

Using the ~ symbol will update z in version x.y.z to its latest version. Assume that the version number of dep1 in the oh-package.json5 file of the app is as follows:

"dependencies": {
  "dep1": "~1.1.1"
}

Although the latest version is 1.2.2, running the ohpm update command will update the version to dep1@1.1.2 due to the use of the ~ symbol (~1.1.1 constrains the version to 1.1.1 ≤ version < 1.2.0, and 1.1.2 is the latest version that satisfies this constraint).

[h2]Tag Dependencies

If a tag is used, dependencies will be updated to the version corresponding to the tag. Assume that the version number of dep1 in the oh-package.json5 file of the app is as follows:

"dependencies": {
  "dep1": "tag:release"
}

If the release tag is updated to point to version 1.2.2, running ohpm update --tag-filter ^r will update dep1 from 1.2.0 to 1.2.2. As dep1 is imported through the release tag, and the release tag matches the ^r regex pattern specified by --tag-filter, ohpm will obtain dep1 at 1.2.2.

[h2]^ Dependency with Version Earlier than 1.0.0