Sets user-level configuration items of ohpm.
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>.
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.
ohpm config set <key> <value>
Writes data in the format of <key> = <value> to the .ohpmrc file in the user-level directory.
Example
ohpm config set log_level debug
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
ohpm config get log_level
info
Example 2
ohpm config get log_level
debug
Example 3
ohpm config get
; "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
ohpm config list alias: ls
Shows the list of configuration items.
Example
ohpm config list or ohpm config ls
; "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
ohpm config delete <key>
Deletes the specified key from the .ohpmrc file in the user-level directory.
Example
registry=http://localhost:8088/repos/ohpm strict_ssl=false log_level=debug
ohpm config delete registry
strict_ssl=false log_level=debug
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
Example
ohpm config encrypt --crypto_path D:\path\to\empty_dir
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
crypto_path=D:\path\to\empty_dir
Non-first-time usage
Example
ohpm config encrypt
Please enter the password to be encrypted: ohpm INFO: encrypted result: security:01:61AE9D3219664B7B785XXXXX:201f713d625daddafcb12198ea9d5121xxxxxx
Ciphertext usage
The generated ciphertext can be configured in the project-level or user-level .ohpmrc file, which is used for sensitive configuration items.
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",
} Specifies the path of the encryption component for data encryption. The following describes different situations of the specified path:
// 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
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.
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.