# environment-configuration

> Load environment configuration from json

Latest version **3.1.0** (published 2024-09-17) · 0 weekly downloads

## Install

```sh
npm install environment-configuration
pnpm add environment-configuration
yarn add environment-configuration
bun add environment-configuration
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2024-09-17 |
| First published | 2022-03-07 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 21.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dan Hunt |
| Maintainers | dkhunt27 |

## Links

- npm: https://www.npmjs.com/package/environment-configuration
- Repository: https://dkhunt27@github.com/dkhunt27/environment-configuration
- Homepage: https://github.com/dkhunt27/environment-configuration
- Issues: https://github.com/dkhunt27/environment-configuration/issues
- npm.io page: https://npm.io/package/environment-configuration

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [@aws-sdk/client-ssm](https://npm.io/package/@aws-sdk/client-ssm.md) ^3.226.0
- [@aws-sdk/credential-providers](https://npm.io/package/@aws-sdk/credential-providers.md) ^3.226.0

## Recent versions

- 3.1.0 (latest) — 2024-09-17
- 3.0.0 — 2023-03-22
- 0.0.0 — 2023-03-22
- 1.2.0 — 2023-03-22
- 1.1.0 — 2022-12-02
- 2.0.1 — 2022-12-01
- 2.0.0 — 2022-12-01
- 1.0.0 — 2022-07-06
- 0.1.5 — 2022-03-08
- 0.1.4 — 2022-03-07
- 0.1.3 — 2022-03-07
- 0.1.2 — 2022-03-07
- 0.1.1 — 2022-03-07
- 0.1.0 — 2022-03-07

## README

# environment-configuration

Loads environment configuration from json file or processes an in memory environment configuration object.

This merges the variables specified in the base (default) with an environment specified set. It will interpolate any env variables. Finally it will process any instructions contained in the variable value. Currently env variable replacing and AWS SSM variable replacing is supported.

![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/dkhunt27/e35a3788f0a2b9faec15f7869073a515/raw/addd887c647eaf07b7f6034581f00f8393f90877/environment-configuration__heads_main.json)

## Instructions

### Environment Variable Instruction

If the instruction starts with `env::` the variable will be replaced with the matching env variable.

```bash
# instruction and env var VAR_A=abc
env::VAR_A

# output
abc
```

### SSM Variable Instruction

If the instruction starts with `ssm::` the variable will be replaced with the matching ssm param variable.

```bash
# instruction and ssm param /ssm/param/varA=def
ssm::/ssm/param/varA

# output
def
```

## Example

```bash

# config file and env var VAR_D=abc and ssm param /ssm/param/varE=def
{
   base: {
      varA: 'baseA',
      varB: 'baseB',
      varD: 'env::VAR_D',
   },
   dev: {
      varA: 'env1A',
      varC: 'env1C'
      varE: 'ssm::/ssm/param/varE'
   },
   prod: {
      varA: 'env1A',
      varC: 'env1C'
   }
 }

# output with appEnv = dev and env var VAR_D=abc and ssm param /ssm/param/varE=def
{
  varA: 'env1A',
  varB: 'baseB',
  varC: 'env1C',
  varD: 'abc',  # result of env::VAR_D
  varE: 'def',  # result of ssm::/ssm/param/varE
}
```

## Publishing

- Make changes
- Create git commit using feat: for new features or fix: for updates
- Run yarn release:major, release:minor, release:patch for appropriate update (this will bump version number appropriately)
- Make PR back to main
- Upon merge to main, it will kick off action that will publish to npm

---
_Source: https://npm.io/package/environment-configuration · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
