# @adobe/aio-lib-env

> Adobe I/O lib for determining dev environment

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

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2024-02-08 |
| First published | 2021-03-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 31.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| 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-env
- Repository: https://github.com/adobe/aio-lib-env
- Issues: https://github.com/adobe/aio-lib-env/issues
- npm.io page: https://npm.io/package/@adobe/aio-lib-env

## Dependencies (2)

- [@adobe/aio-lib-core-config](https://npm.io/package/@adobe/aio-lib-core-config.md) ^5.0.0
- [@adobe/aio-lib-core-logging](https://npm.io/package/@adobe/aio-lib-core-logging.md) ^3.0.0

## Recent versions

- 3.0.1 (latest) — 2024-02-08
- 2.0.0-pre.2024-01-08.afe0f46e (next) — 2024-01-08
- 3.0.0 — 2024-01-10
- 2.0.0 — 2022-08-19
- 1.1.0-pre.2022-06-06.9947571f — 2022-06-06
- 1.1.0 — 2021-04-09
- 1.0.0 — 2021-03-10

## README

<!--
Copyright 2021 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.
-->

[![Version](https://img.shields.io/npm/v/@adobe/aio-lib-env.svg)](https://npmjs.org/package/@adobe/aio-lib-env)
[![Downloads/week](https://img.shields.io/npm/dw/@adobe/aio-lib-env.svg)](https://npmjs.org/package/@adobe/aio-lib-env)
![Node.js CI](https://github.com/adobe/aio-lib-env/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-env/master.svg?style=flat-square)](https://codecov.io/gh/adobe/aio-lib-env/)

# Adobe I/O Env Lib

This is a helper library that is to be used in the Adobe I/O CLI and SDKs to determine the environment to run in, whether `prod`, or `stage`.


### Installing

```bash
$ npm install @adobe/aio-lib-env 
```

### Usage

Determining the Environment
```javascript
const { 
  getCliEnv, /* function */ 
  setCliEnv, /* function */
  SUPPORTED_ENVS, /* array<string> */
  DEFAULT_ENV, /* string */
  PROD_ENV, /* string */
  STAGE_ENV /* string */
} = require('@adobe/aio-lib-env')

// getCliEnv defaults to PROD_ENV if the global config key is not set, or is set to an unknown env
const env = getCliEnv() 
// do something based on the env - switch to prod or stage endpoints, for example
```

Setting the Environment (.aio)
```json
{
  cli: {
    env: "prod"
  }
}
```

Setting the Environment (.env)
```ini
AIO_CLI_ENV=prod
```

Setting the Environment (in code)
```javascript
const { setCliEnv, PROD_ENV, STAGE_ENV } = require('@adobe/aio-lib-env')

setCliEnv(PROD_ENV)
setCliEnv(STAGE_ENV)
setCliEnv('delta-quadrant') // throws Error
```

### Debug Logs

```bash
LOG_LEVEL=debug <your_call_here>
```

Prepend the `LOG_LEVEL` environment variable and `debug` value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.

### Contributing

Contributions are welcome! 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-env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
