2.0.0 • Published 12 months ago

local-npm-config v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
12 months ago

local-npm-config (CLI)

License npm.io npm.io npm.io XO code style

Do you work across multiple machines on JavaScript projects? If yes is your answer, then you might want to answer the question:

How many times do you type npm init -y in your favorite shell?

What if you could keep a stable npm configuration across those machines and set up sensible defaults for npm?

The primary goal of this project is to make it easy to create, share and apply npm init configuration files without exposing your ".npmrc" content, which might contain sensible info about your npm account (tokens maybe?).

Installation

Note: to use this CLI application, you have to have installed Node.js and a console you can run commands into. The minimum required version of Node.js is: 8 - codename "Carbon".

In your console, run the following command:

$ npm install -g local-npm-config

Usage

In your console, all the following commands print the help of the module:

  • $ local-npm-config --help
  • $ localnpm -h

Export configuration to a file

You can export the npm init configuration from a file so that you can share it between environments easily. This feature goes through the CLI prompt and writes the result into a JSON file in the current working directory (the directory in which you run the app).

 $ local-npm-config -e

Note: at the moment, you can not change the name of the generated file.

The generated file, named "local-npm-config.json", has the following structure:

{
  "author": {
    "name": "<name>",
    "email": "<email>",
    "url": "<url>"
  },
  "license": "<license>",
  "version": "<version>"
}

To minimize file size (even though it currently isn't a problem), if a value is left blank, it does not exist in the generated file. The app validates the exported configuration against a JSON schema before writing it to the file.

This command supports the dry run option (-d argument).

Apply a configuration from a file

You can apply the npm init configuration from a file, maybe exported by this very app, so that you can keep configurations synced easily.

 $ local-npm-config -i <local_or_remote_path>

For example, if my configuration lives on this gist, I could use either one of the following commands to apply it to my current local environment:

 # First option!
 # Since I need the raw JSON file from the gist, I just copied the URL of the "raw" gist
 $ local-npm-config -i https://gist.githubusercontent.com/niktekusho/b4f229c24db26512f02b552401053a7c/raw/188f486f0433759bf9b3a2b6c3de29111cd38fc1/npm-init-config.json

# Second option!
# Use the browser to download the file into my "downloads" directory and give the CLI its path
 $ local-npm-config -i ~/downloads/npm-init-config.json

This command supports the dry run option (-d argument).