bini-env 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +129 -0
- package/package.json +1 -1
package/Readme.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# bini-env
|
|
2
|
+
|
|
3
|
+
A lightweight Vite plugin that enhances your dev and preview server output with a clean startup banner and detected `.env` files.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Replaces Vite's default header with a clean custom banner
|
|
8
|
+
- Automatically detects and displays active `.env` files
|
|
9
|
+
- Supports `dev` and `preview` modes
|
|
10
|
+
- Fully customizable logo and behavior
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
```bash
|
|
14
|
+
npm install bini-env --save-dev
|
|
15
|
+
# or
|
|
16
|
+
pnpm add -D bini-env
|
|
17
|
+
# or
|
|
18
|
+
yarn add -D bini-env
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
```ts
|
|
23
|
+
// vite.config.ts
|
|
24
|
+
import { defineConfig } from 'vite';
|
|
25
|
+
import biniEnv from 'bini-env';
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
plugins: [biniEnv()]
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Output Example
|
|
33
|
+
|
|
34
|
+
**Dev mode**
|
|
35
|
+
```
|
|
36
|
+
ß Bini.js (dev)
|
|
37
|
+
✓ Environments: .env.local, .env
|
|
38
|
+
➜ Local: http://localhost:5173/
|
|
39
|
+
➜ Network: http://192.168.1.10:5173/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Preview mode**
|
|
43
|
+
```
|
|
44
|
+
ß Bini.js (preview)
|
|
45
|
+
✓ Environments: .env.local, .env
|
|
46
|
+
➜ Local: http://localhost:4173/
|
|
47
|
+
➜ Network: http://192.168.1.10:4173/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Options
|
|
51
|
+
|
|
52
|
+
| Option | Type | Default | Description |
|
|
53
|
+
|--------|------|---------|-------------|
|
|
54
|
+
| `enabled` | `boolean` | `true` | Enable or disable the plugin |
|
|
55
|
+
| `clearViteHeader` | `boolean` | `true` | Replace Vite's default startup header |
|
|
56
|
+
| `logo` | `string` | `'ß'` | Custom logo or text shown in the banner |
|
|
57
|
+
|
|
58
|
+
### Example with options
|
|
59
|
+
```ts
|
|
60
|
+
biniEnv({
|
|
61
|
+
logo: '🚀',
|
|
62
|
+
clearViteHeader: true,
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Detected `.env` Files
|
|
67
|
+
|
|
68
|
+
The plugin checks for the following files in your project root (in priority order):
|
|
69
|
+
|
|
70
|
+
1. `.env.local`
|
|
71
|
+
2. `.env.[NODE_ENV].local`
|
|
72
|
+
3. `.env.[NODE_ENV]`
|
|
73
|
+
4. `.env`
|
|
74
|
+
|
|
75
|
+
Any files found are displayed in the banner on startup.
|
|
76
|
+
|
|
77
|
+
## Modes
|
|
78
|
+
|
|
79
|
+
| Mode | Trigger | Banner |
|
|
80
|
+
|------|---------|--------|
|
|
81
|
+
| Development | `vite dev` | `ß Bini.js (dev)` |
|
|
82
|
+
| Preview | `vite preview` | `ß Bini.js (preview)` |
|
|
83
|
+
|
|
84
|
+
> **Note:** `bini-env` is a server-only plugin (`apply: 'serve'`) and does not run during `vite build`.
|
|
85
|
+
|
|
86
|
+
## API
|
|
87
|
+
|
|
88
|
+
The following utilities are exported for use outside of the plugin if needed.
|
|
89
|
+
|
|
90
|
+
### `detectEnvFiles(projectRoot?: string): DetectedEnvFile[]`
|
|
91
|
+
|
|
92
|
+
Scans a directory for `.env` files and returns an array of matches.
|
|
93
|
+
```ts
|
|
94
|
+
import { detectEnvFiles } from 'bini-env';
|
|
95
|
+
|
|
96
|
+
const files = detectEnvFiles('/my/project');
|
|
97
|
+
// [{ name: '.env.local', path: '/my/project/.env.local' }, ...]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Defaults to `process.cwd()` if no path is provided.
|
|
101
|
+
|
|
102
|
+
### `formatEnvFilesForDisplay(envFiles: DetectedEnvFile[]): string`
|
|
103
|
+
|
|
104
|
+
Formats a list of detected env files into a display-ready console string.
|
|
105
|
+
```ts
|
|
106
|
+
import { detectEnvFiles, formatEnvFilesForDisplay } from 'bini-env';
|
|
107
|
+
|
|
108
|
+
const files = detectEnvFiles();
|
|
109
|
+
console.log(formatEnvFilesForDisplay(files));
|
|
110
|
+
// ✓ Environments: .env
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Types
|
|
114
|
+
```ts
|
|
115
|
+
interface BiniEnvPluginOptions {
|
|
116
|
+
enabled?: boolean;
|
|
117
|
+
clearViteHeader?: boolean;
|
|
118
|
+
logo?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface DetectedEnvFile {
|
|
122
|
+
name: string;
|
|
123
|
+
path: string;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT
|