Remember, last time we mentioned that nucm can help us manage NPM account information with a few simple commands. Click here for the previous article
Since Nucm version 1.5.0, it has been able to manage the account information of all sources, and it can also manage the user accounts logged in by npm login. These two functions are mainly introduced below:
- Added account management capability for other sources ( d12f24d )
- Added nucm save command to query whether the current account information is stored and saved ( 0e9d5a3 )
How to manage accounts from other sources
When we clone
create a new project, the first step is generally to install dependencies, which need to be executed npm install
(or yarn) in the terminal, and then npm will download project dependencies from registry.npmjs.org/source (npm official source). Because we are in China, we need to use the taobao mirror source to improve the download speed. If the team has built their own npm private storage, they must use the private source.
Faced with so many sources, can we all remember the corresponding account number? How should we manage accounts?
The latest version of Nucm provides such a capability, which can help us simply manage the account information of each source.
1. Add accounts from different sources
There is only one principle for adding accounts: the accounts you add or save will be recorded under the current source information.
That is to say, if it is currently an npm source, the new account you add will be recorded under the npm source information. If the current source is taobao, the newly added account will be recorded under the taobao source information.
【Add account instruction】:nucm add <name> <access-tokens>
# 添加账号 beezen
$ nucm add beezen xxxxxxxxxxxxxxxxx
复制代码
[Save current account command]: nucm save
(The specific content is described in detail below)
注:怎么查看当前环境是什么源?
[Method 1]: The terminal npm config get registry
can .
[Method 2 (recommended)]: Manage and view through the nrm tool.
$ nrm ls
npm ---------------- https://registry.npmjs.org/
yarn --------------- https://registry.yarnpkg.com/
tencent ------------ https://mirrors.cloud.tencent.com/npm/
cnpm --------------- https://r.cnpmjs.org/
* taobao ------------- https://registry.npmmirror.com/
npmMirror ---------- https://skimdb.npmjs.com/registry/
复制代码
2. View the account information of the current source
# 查看当前源账号
$ nucm ls
beezend -- xxxxxx......xxxx
beezen --- xxxxxx......xxxx
* beeze ---- xxxxxx......xxxx
# 查看当前源账号,详细信息
$ nucm ls -l
beezend -- xxxxxxxxxxxxxxxx
beezen --- xxxxxxxxxxxxxxxx
* beeze ---- xxxxxxxxxxxxxxxx
复制代码
3. View account information from all sources
# 查看所有源账号
$ nucm ls -a
【npm】
beezend -- xxxxxx......xxxx
beezen --- xxxxxx......xxxx
* beeze ---- xxxxxx......xxxx
【maclocal】
* test ----- xxxxxx......xxxx
# 查看所有源账号-详细
$ nucm ls -al
【npm】
beezend -- xxxxxxxxxxxxxxxx
beezen --- xxxxxxxxxxxxxxxx
* beeze ---- xxxxxxxxxxxxxxxx
【maclocal】
* test ----- xxxxxxxxxxxxxxxx
复制代码
How to manage the accounts logged in by npm login
Initially, the 1.0 version of nucm only managed access tokens for npm accounts, and we also know that access tokens are more used in the continuous integration of projects. For individual developers, it is still accustomed to using account numbers and passwords. When you want to switch accounts, it is generally performed to npm login
enter account number and password, and then log in through the second verification of the mobile phone, and then the npm
package can be released. To be honest, this release process is quite long and cumbersome.
Now, we can use nucm to manage the accounts of individual developers, no longer need to rely on memory.
In the latest version 1.5.0 of nucm, the function of saving the current account has been added. The developer only needs to execute the nucm save
command , and nucm will automatically detect whether the current user is logged in and whether the current login account needs to be saved (if the account has been saved by nucm, it does not need to be saved repeatedly). The successfully saved account will be recorded in the current source information. Down. Then we nucm ls
can nucm use <name>
quickly switch accounts by viewing the list of saved account information.
The basic operation steps are as follows:
Finally, in order to make it easier to understand, the overall flow chart of the nucm save
instruction :
finally
Finally, we welcome everyone in the open source community to provide more valuable suggestions, and welcome to Star + Fork + Watch .
Git project address: github.com/beezen/nucm