# prenv

> 在启动前设置具名环境变量 & 生成环境变量类型到 .d.ts

Latest version **2.0.0** (published 2023-12-13) · MIT license · 0 weekly downloads

## Install

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

Provides the commands `prenv`, `prenv-type`.

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-12-13 |
| First published | 2023-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | 杨伟杰 |
| Maintainers | sia-fl |
| Keywords | ts, lib, start |

## Links

- npm: https://www.npmjs.com/package/prenv
- Repository: https://github.com/sia-fl/prenv
- Homepage: https://github.com/sia-fl/prenv#readme
- Issues: https://github.com/sia-fl/prenv/issues
- npm.io page: https://npm.io/package/prenv

## Dependencies (2)

- [dotenv](https://npm.io/package/dotenv.md) ^16.3.1
- [minimist](https://npm.io/package/minimist.md) ^1.2.8

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-12-13
- 1.0.5 — 2023-12-01
- 1.0.4 — 2023-12-01
- 1.0.3 — 2023-11-30
- 1.0.2 — 2023-11-30
- 1.0.1 — 2023-11-30
- 1.0.0 — 2023-11-29

## README

English | [中文](./README-zh_CN.md)

## ✨ Feature List

- ❄️ generate the `env.d.ts` file for environment variables into a specified directory
- 💥 initialize environment variables at startup

## 📦 Installation

```bash
npm install prenv
```

```bash
yarn add prenv
```

```bash
pnpm add prenv
```

## 💫 Generate the `env.d.ts` File for Environment Variables into a Specified Directory

```
Usage:

prenv-type --prenv-dir . --prenv-output ./types

// or generate to some workspace app

prenv-type --prenv-dir ./workspace/some-app --prenv-output ./workspace/some-app/types
```

using in package.json

```json
{
  "scripts": {
    "test": "prenv-type --prenv-dir . --prenv-output ./types"
  }
}
```

## 💫 Initialize Environment Variables at Startup

```
Usage: 

prenv --prenv-dir . --prenv-name developer commands

// using for vitest

prenv --prenv-dir . --prenv-name developer vitest

// using for some node app

prenv --prenv-dir . --prenv-name developer node your-app.js

// using for vite

prenv --prenv-dir . --prenv-name developer vite build
```

using in package.json

```json
{
  "scripts": {
    "test": "prenv --prenv-dir . --prenv-name developer vitest",
    "build": "prenv --prenv-dir . --prenv-name developer vite build",
    "start": "prenv --prenv-dir . --prenv-name developer node your-app.js"
  }
}
```

| Name | Alias         |
|------|---------------|
| d    | development   |
|dev   | development   |
| t    | test          |
| p    | production    |
|prod  | production    |

| v2 Params      | Default     |
|----------------|-------------|
| --prenv-dir    | .           |
| --prenv-name   | development |
| --prenv-output | .           |

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