目录

ohpm version

Manages module versions.

Command Format

ohpm version [options] [<newversion> | major | minor | patch]

Description

Executed in the module directory, this command is used to obtain or upgrade a version number and write the data back to oh-package.json5.

Parameter Description

[h2]None

If you run the ohpm version command without any parameter, the version number of the current module is displayed in the standard output.

[h2]newversion

newversion must be set to a valid semantic version. The command overwrites the module's current version with this value and prints it to standard output.

[h2]major

When parameter major is used:

[h2]minor

When parameter minor is used, the major version number is fixed, and the minor and patch version numbers are changed according to the following rules:

[h2]patch

When parameter patch is used, the major and minor version numbers are fixed, and the patch version number is changed according to the following rules:

Options

[h2]prefix

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

[h2]parameterFile

You can append the --pf <string> or --parameterFile <string> parameter to the ohpm version command to specify the path of the parameterization configuration file. Before running this command, ensure that parameterFile is configured in the project-level oh-package.json5 file.

[h2]log_level

In ohpm 6.0.2.636 and later versions, you can append the --log_level <string> parameter to the ohpm version 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.

Example

For the entry module, the version number is 1.0.0, run the following command in the root directory of the current module:

ohpm version

Below is an output example:

Run the following command:

ohpm version 1.0.1-beta.1

Below is an output example:

Run the following command:

ohpm version major

Below is an output example: