# tyenv

> An utility for creation types for `process.env` variables and `.env` file

Latest version **1.2.2** (published 2023-01-13) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install tyenv
pnpm add tyenv
yarn add tyenv
bun add tyenv
```

Provides the command `tyenv`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2023-01-13 |
| First published | 2023-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrii Lytovchenko |
| Maintainers | andr-ii |
| Keywords | nodejs, typescript, javascript, environment variables |

## Links

- npm: https://www.npmjs.com/package/tyenv
- Repository: https://github.com/andr-ii/tyenv
- Homepage: https://github.com/andr-ii/tyenv#readme
- Issues: https://github.com/andr-ii/tyenv/issues
- npm.io page: https://npm.io/package/tyenv

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2023-01-13

## README

# tyenv

[![NPM version][npm-img]][npm-url]
[![Package Build][build-img]][build-url]
[![Coverage Status][coverage-img]][coverage-url]

An utility for creation types for `process.env` variables and `.env` file.

## Installation

```bash
npm i tyenv
```

## Initial types generation

At the very first time you will have to create a `env.d.ts` file.
It will be located at `node_modules/tyenv/lib` directory
and will include all types for `process.env` and `.env` file.

> **Note**
>
> If `.env` file was updated - this script should be re-run manually
> to get all new variables with types for your development process.

Add following script to the `scripts` of your project's `package.json` file:

```json
"tyenv": "tyenv init"
```

Then run:

```bash
npm run tyenv
```

### Usage

Add import:

```ts
// ES6 or TypeScript
import env from 'tyenv';

// CommonJS
const { env } = require('tyenv');
```

All of the `process.env` and the `.env` file variables will be available with types:

<img src="https://github.com/andr-ii/tyenv/blob/master/assets/tyenv.png?raw=true"/>

### '.env' example

```env
# This value will have a 'number' type.
PORT=3000

# This value will have a 'string' type. Quotes ' or " will be removed.
PROJECT='foo-bar'

COMMENT=some-comment # This value will have a 'string' type and this comment will be removed.

# This value will have a 'boolean' type.
IS_JSON=true
```

[npm-img]: https://img.shields.io/npm/v/tyenv.svg
[npm-url]: https://www.npmjs.com/package/tyenv
[build-img]: https://github.com/andr-ii/tyenv/actions/workflows/build.yml/badge.svg
[build-url]: https://github.com/andr-ii/tyenv/actions/workflows/build.yml
[coverage-img]: https://coveralls.io/repos/github/andr-ii/tyenv/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/andr-ii/tyenv?branch=master

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