# @adobe/aio-lib-core-config

> Adobe I/O Configuration Module

Latest version **5.0.1** (published 2024-02-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @adobe/aio-lib-core-config
pnpm add @adobe/aio-lib-core-config
yarn add @adobe/aio-lib-core-config
bun add @adobe/aio-lib-core-config
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2024-02-12 |
| First published | 2019-09-17 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 5 |
| Unpacked size | 34 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Adobe Inc. |
| Maintainers | djaeggi, adobehalls, fullcolorcoder, marbec, tripod, garthdb, lazd, adobe-admin, patrickfulton, trieloff, shazron, krisnye, dcpfsdk, natebaldwin, devongovett, aspro83, symanovi, dpfister, stefan-guggisberg, korra, rofe, kptdobe |

## Links

- npm: https://www.npmjs.com/package/@adobe/aio-lib-core-config
- Repository: https://github.com/adobe/aio-lib-core-config
- Homepage: https://github.com/adobe/aio-lib-core-config#readme
- Issues: https://github.com/adobe/aio-lib-core-config/issues
- npm.io page: https://npm.io/package/@adobe/aio-lib-core-config

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [hjson](https://npm.io/package/hjson.md) ^3.1.2
- [dotenv](https://npm.io/package/dotenv.md) 16.3.1
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.0.0

## Recent versions

- 5.0.1 (latest) — 2024-02-12
- 4.0.0-pre.2024-01-08.d04a66d9 (next) — 2024-01-08
- 5.0.0 — 2024-01-10
- 4.0.0 — 2023-07-06
- 3.1.0 — 2023-01-23
- 3.0.0 — 2022-08-18
- 2.0.1-pre.2022-06-06.07ac3186 — 2022-06-06
- 2.0.1 — 2021-06-15
- 2.0.0 — 2020-07-03
- 1.2.8 — 2020-01-21
- 1.2.7 — 2020-01-21
- 1.2.6 — 2020-01-20
- 1.2.5 — 2020-01-17
- 1.2.4 — 2020-01-13
- 1.2.3 — 2020-01-13
- … 5 more at https://npm.io/package/@adobe/aio-lib-core-config/versions

## README

<!--
Copyright 2018 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
-->

@adobe/aio-lib-core-config
=======================

[![Version](https://img.shields.io/npm/v/@adobe/aio-lib-core-config.svg)](https://npmjs.org/package/@adobe/aio-lib-core-config)
[![Downloads/week](https://img.shields.io/npm/dw/@adobe/aio-lib-core-config.svg)](https://npmjs.org/package/@adobe/aio-lib-core-config)
![Node.js CI](https://github.com/adobe/aio-lib-core-config/workflows/Node.js%20CI/badge.svg)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Codecov Coverage](https://img.shields.io/codecov/c/github/adobe/aio-lib-core-config/master.svg?style=flat-square)](https://codecov.io/gh/adobe/aio-lib-core-config/)
[![Size(minified)](https://badgen.net/bundlephobia/min/@adobe/aio-lib-core-config)](https://npmjs.org/package/@adobe/aio-lib-core-config)

This is a nodejs module to allow management of persistent and environment variable configuration.


The module can be added to your project with:

```javascript
npm install @adobe/aio-lib-core-config --save
```

Here is a snippet:

```javascript
const config = require('@adobe/aio-lib-core-config')

// set a key value
config.set('pgb.authtoken', 1234)

// reload data from files and environmental variables
config.reload()

// get all stored data
config.get()

// get data from a given key
config.get('pgb.authtoken')

// delete a key
config.delete('pgb.authtoken')
```

## Persistent File Locations

### User Configuration

The user default location is: 

1. **ENV['AIO_CONFIG_FILE']**
1. **ENV['XDG_CONFIG_HOME']/aio**
1. **\<HOME>/.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.

Note: All environment variable names will be converted to uppercase. 

1. In the event that there are duplicate environment variables, if the uppercase version exists, it will be hoisted. 

```
aa=1 
aA=2
AA=3 <-- Hoisted as AA
```

2. In the event that there are duplicate environment variables with multiple case variations, the first entry will be hoisted. 

```
aa=1 <-- Hoisted as AA
Aa=2
```

## 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_\<PLUGIN>_\<KEY> 

```bash
$ AIO_PGB_AUTHTOKEN=1234 node
> config.get('pgb.authtoken')
1234

$ AIO_PGB_AUTH__TOKEN=1234 node # use double underscores to specify an underscore
> config.get('pgb.auth_token')
1234
```
## Explore

`goto` [API](./doc/api.md)

## Contributing
Contributions are welcomed! Read the [Contributing Guide](./.github/CONTRIBUTING.md) for more information.
 
## Licensing

This project is licensed under the Apache V2 License. See [LICENSE](LICENSE) for more information.

---
_Source: https://npm.io/package/@adobe/aio-lib-core-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
