项目作者: adobe

项目描述 :
Configuration module for use by aio-cli plugins
高级语言: JavaScript
项目地址: git://github.com/adobe/aio-cli-config.git
创建时间: 2019-04-16T00:40:55Z
项目社区:https://github.com/adobe/aio-cli-config

开源协议:

下载


DEPRECATED, go to https://github.com/adobe/aio-cna-core-config

aio-cli-config

oclif
@adobe/aio-cli-config"">Version
@adobe/aio-cli-config"">Downloads/week
Build Status
License Greenkeeper badge
Codecov Coverage

This is a nodejs module to allow management of persistant and environment variable configuration by aio-cli plugins.

The module can be added to your project with:

  1. > yarn add aio-cli-config
  2. or
  3. > npm install aio-cli-config --save

Here is a snippet:

  1. const config = require('aio-cli-config')
  2. // set a key value
  3. config.set('pgb.authtoken', 1234)
  4. // reload data from files and environmental variables
  5. config.reload()
  6. // get all stored data
  7. config.get()
  8. // get data from a given key
  9. config.get('pgb.authtoken')
  10. // delete a key
  11. config.delete('pgb.authtoken')

Peristent File Locations

User Configuration

The user default location is:

  1. ENV[‘AIO_CONFIG_FILE’]
  2. ENV[‘XDG_CONFIG_HOME’]/aio
  3. \/.config/aio

depending on whether the specified environmental variables exist

Project Configuration

Local configuration is loaded from $PWD/.aio

Dot Env Configuration

A local .env file is also loaded. This file can contain environmental variables

Resolving Values

Resolving configuration is done in two steps:

  1. .env file is read, parsed and hoisted to environment variables ( process.env )
  2. user and local files are read

Inheritance is similar to NPMRC and can be set using user file, project file and matching environment variables. Values are read and merged in the following order in increasing priority:

  1. user config eg. ~/.config/aio
  2. project config eg. $PWD/.aio
  3. environment variables matching AIO\\
  1. $ AIO_PGB_AUTHTOKEN=1234 node
  2. > config.get('pgb.authtoken')
  3. 1234
  4. $ AIO_PGB_AUTH__TOKEN=1234 node # use double underscores to specify an underscore
  5. > config.get('pgb.auth_token')
  6. 1234

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.