目录

ohpm config

Sets user-level configuration items of ohpm.

Command Format

ohpm config set <key> <value>
ohpm config get <key>
ohpm config delete <key>
ohpm config list
ohpm config encrypt [options]

Information in the configuration file is in the format of <key> = <value>.

Description

ohpm obtains its configuration settings from the command line and the .ohpmrc file. For more information about the .ohpmrc file and available configuration items, see ohpmrc.

ohpm config is used to configure only default fields, and only the .ohpmrc file in the user-level directory can be modified. For details about the default fields, see ohpmrc.

Subcommands

[h2]set

ohpm config set <key> <value>

Writes data in the format of <key> = <value> to the .ohpmrc file in the user-level directory.

Example

  1. The following uses log_level as an example to describe how to change the value to debug (options: debug, info, warn, and error).
    ohpm config set log_level debug
  2. After the command is executed successfully, log_level=debug is displayed in the /.ohpm/.ohpmrc file in the user directory.

[h2]get

ohpm config get <key>

Outputs, in standard mode, values obtained from the command line, project-level .ohpmrc file, and user-level .ohpmrc file (in descending order of priority).

If no key value is provided, the execution result of this command is the same as that of the ohpm config list command.

Example 1

  1. Assume that log_level is set to info in the project-level .ohpmrc file and set to debug in the user-level .ohpmrc file. Run the following command in any directory of the project:
    ohpm config get log_level
  2. After the command is executed successfully, the value of log_level is printed on the console.
    info

Example 2

  1. After completing steps in Example 1, delete the project-level .ohpmrc file and run the get command again.
    ohpm config get log_level
  2. After the command is executed successfully, the value of log_level is printed on the console.
    debug

Example 3

  1. Run the ohpm config get command without the <key> value.
    ohpm config get
  2. After the command is executed successfully, the .ohpmrc configurations are printed on the console.
    ; "user" config from C:\Users\username\.ohpm\.ohpmrc
    
    registry="http://localhost:8088/repos/ohpm"
    strict_ssl = false
    log_level = "debug"
    
    ; "user" config from C:\Users\username\.ohpm\.ohpmrc
    ; node bin location = C:\Program Files\nodejs\node.exe
    ; node version = v18.19.1
    ; ohpm local prefix = C:\Users\username
    ; ohpm version = 5.1.2-rc.2
    ; cwd = C:\Users\username
    ; HOME = C:\Users\username

[h2]list

ohpm config list
alias: ls

Shows the list of configuration items.

Example

  1. Run the list command.
    ohpm config list or ohpm config ls
  2. After the command is executed successfully, the .ohpmrc configurations are printed on the console.
    ; "user" config from C:\Users\username\.ohpm\.ohpmrc
    
    registry="http://localhost:8088/repos/ohpm"
    strict_ssl = false
    log_level = "debug"
    
    ; "user" config from C:\Users\username\.ohpm\.ohpmrc
    ; node bin location = C:\Program Files\nodejs\node.exe
    ; node version = v18.19.1
    ; ohpm local prefix = C:\Users\username
    ; ohpm version = 5.1.2-rc.2
    ; cwd = C:\Users\username
    ; HOME = C:\Users\username

[h2]delete

ohpm config delete <key>

Deletes the specified key from the .ohpmrc file in the user-level directory.

Example

  1. Obtain the original content in the user-level .ohpmrc file.
    registry=http://localhost:8088/repos/ohpm
    strict_ssl=false
    log_level=debug
  2. Run the delete command.
    ohpm config delete registry
  3. After the command is executed successfully, the .ohpmrc file contains the following content:
    strict_ssl=false
    log_level=debug

[h2]encrypt

ohpm config encrypt [options]

Encrypts the data from the standard input using the encryption component and outputs the ciphertext to the standard output.

First-time usage

Non-first-time usage

Ciphertext usage

The generated ciphertext can be configured in the project-level or user-level .ohpmrc file, which is used for sensitive configuration items.

Options

[h2]json

You can append the -j or --json parameter to the config list command to output all configuration items and default values in JSON format.

// Example
// 1. Run the list command and output the result in JSON format.
ohpm config list -j or ohpm config list --json
// 2. Check the command execution result.
{
  "registry": "http://localhost:8088/repos/ohpm", 
  "strict_ssl": false,
  "log_level": "info",
}

[h2]crypto_path

Specifies the path of the encryption component for data encryption. The following describes different situations of the specified path:

  1. If the specified path does not exist, the directory is automatically created and an encryption component is generated.
  2. If the specified path is an empty directory, the encryption component is automatically generated in the directory.
  3. If the specified path already has an encryption component, the existing encryption component will be used.
// Example 1
// 1. Run the encrypt --crypto_path <string> command, where the specified path is an empty directory.
ohpm config encrypt --crypto_path D:\path\to\empty_dir
// 2. After the command is executed successfully, an encryption component is generated in the specified path to encrypt user input, which is invisible during entry.
ohpm INFO: Attempted to create a crypto component at the "D:\path\to\empty_dir" path...
ohpm INFO: The crypto component has been created successfully.
Please enter the password to be encrypted:
ohpm INFO: encrypted result:
security:01:61AE9D3219664B7B785XXXXX:201f713d625daddafcb12198ea9d5121xxxxxx

// Example 2
// 1. Run encrypt --crypto_path <string> with the specified path set to an encryption component.
ohpm config encrypt --crypto_path D:\path\to\crypto_dir
// 2. After successful execution, encrypt user input, which is invisible during entry.
Please enter the password to be encrypted:
ohpm INFO: encrypted result:
security:01:61AE9D3219664B7B785XXXXX:201f713d625daddafcb12198ea9d5121xxxxxx

[h2]log_level

In ohpm 6.0.2.636 and later versions, you can append the --log_level <string> parameter to the command to specify the log level (info, debug, warn, or error) for the 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.