env-checklist 1.1.2 โ†’ 1.2.9

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 CHANGED
@@ -3,14 +3,17 @@
3
3
  A lightweight, color-coded CLI tool to ensure your local environment variables match your `.env.example` before you launch your app.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/env-checklist.svg)](https://www.npmjs.com/package/env-checklist)
6
- [![license](https://img.shields.io/npm/l/env-checklist.svg)](https://github.com/YOUR_GITHUB_USERNAME/env-checklist)
6
+ [![license](https://img.shields.io/npm/l/env-checklist.svg)](https://github.com/tangorishi/env-checklist)
7
7
 
8
8
  ## ๐Ÿš€ Why use this?
9
+
9
10
  How many times has your app crashed because you forgot to add a new API key to your `.env` file? `env-checklist` prevents that by comparing your active `.env` against your template.
10
11
 
11
12
  - **๐ŸŽจ Beautiful Terminal Output**: Uses Chalk for high-contrast success/error messages.
12
13
  - **๐Ÿ›ก๏ธ Robust Parsing**: Automatically ignores comments and empty lines.
13
14
  - **๐Ÿ“ฆ Zero Config**: Works out of the box with any Node.js project.
15
+ - **๐Ÿ”‘ Optional Keys**: Mark variables as optional directly in your `.env.example`.
16
+ - **๐Ÿ›  Programmatic API**: Use `preflight()` or `preflightSafe()` directly in your code.
14
17
 
15
18
  ---
16
19
 
@@ -18,5 +21,178 @@ How many times has your app crashed because you forgot to add a new API key to y
18
21
 
19
22
  ### Run once (Recommended)
20
23
  You don't even need to install it. Just run this in your project root:
24
+
25
+ ```bash
26
+ npx env-checklist@latest
27
+ ```
28
+
29
+ ### Install globally
30
+ ```bash
31
+ npm install -g env-checklist
32
+ env-checklist
33
+ ```
34
+
35
+ ### Install as a dev dependency
36
+ ```bash
37
+ npm install --save-dev env-checklist
38
+ ```
39
+
40
+ Add it to your `package.json` scripts to run before starting your app:
41
+
42
+ ```json
43
+ "scripts": {
44
+ "prestart": "env-checklist",
45
+ "start": "node dist/index.js"
46
+ }
47
+ ```
48
+
49
+ ---
50
+
51
+ ## ๐Ÿšฉ CLI Flags
52
+
53
+ | Flag | Alias | Description |
54
+ |------|-------|-------------|
55
+ | `--verbose` | | Show a status line for every key checked |
56
+ | `--fix` | | Auto-generate a `.env` file from `.env.example` with empty placeholders |
57
+ | `--path <file>` | | Use a custom `.env.example` path (useful in monorepos) |
58
+ | `--version` | `-v` | Show the current version |
59
+ | `--help` | `-h` | Show the help message |
60
+
61
+ ### Examples
62
+
21
63
  ```bash
22
- npx env-checklist@latest
64
+ # Basic check
65
+ npx env-checklist
66
+
67
+ # See every key's status
68
+ npx env-checklist --verbose
69
+
70
+ # Auto-generate a .env scaffold
71
+ npx env-checklist --fix
72
+
73
+ # Use a custom .env.example path (monorepos)
74
+ npx env-checklist --path apps/api/.env.example
75
+
76
+ # Check version
77
+ npx env-checklist --version
78
+ ```
79
+
80
+ ### `--verbose` output example
81
+
82
+ ```
83
+ โœˆ๏ธ Checking environment variables...
84
+
85
+ KEY TYPE STATUS
86
+ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
87
+ PORT required โœ… present
88
+ API_KEY required โœ… present
89
+ DATABASE_URL required โŒ missing
90
+ SENTRY_DSN optional โž– not set
91
+
92
+ โŒ Preflight Failed!
93
+
94
+ Missing required variables:
95
+ โœ– DATABASE_URL
96
+
97
+ 2 passed ยท 1 failed ยท 4 total
98
+ ```
99
+
100
+ ### `--fix` output example
101
+
102
+ ```bash
103
+ npx env-checklist --fix
104
+ # โœ… .env file created from .env.example.
105
+ # 3 variable(s) scaffolded. Fill in the values before launching.
106
+ ```
107
+
108
+ ---
109
+
110
+ ## ๐Ÿ”‘ Optional Keys
111
+
112
+ Mark any variable as optional in your `.env.example` by adding `# optional` to the end of the line. Optional keys are loaded into the config if present but never cause a failure.
113
+
114
+ ```bash
115
+ # .env.example
116
+ PORT=
117
+ API_KEY=
118
+ DATABASE_URL=
119
+ SENTRY_DSN= # optional
120
+ LOG_LEVEL= # optional
121
+ ```
122
+
123
+ ---
124
+
125
+ ## ๐Ÿ“ฆ Programmatic API
126
+
127
+ ### `preflight(keys)` โ€” strict mode
128
+
129
+ Throws a `PreflightError` if any required key is missing. Accepts a plain array or an options object.
130
+
131
+ ```ts
132
+ import { preflight } from 'env-checklist';
133
+
134
+ // Simple โ€” required keys only
135
+ const config = preflight(['PORT', 'API_KEY', 'DATABASE_URL']);
136
+
137
+ // With optional keys
138
+ const config = preflight({
139
+ required: ['PORT', 'API_KEY'],
140
+ optional: ['SENTRY_DSN', 'LOG_LEVEL'],
141
+ });
142
+
143
+ console.log(config.PORT); // '3000'
144
+ ```
145
+
146
+ ### `preflightSafe(keys)` โ€” safe mode
147
+
148
+ Never throws. Returns a result object โ€” ideal when you want to handle errors yourself.
149
+
150
+ ```ts
151
+ import { preflightSafe } from 'env-checklist';
152
+
153
+ const result = preflightSafe({
154
+ required: ['PORT', 'API_KEY'],
155
+ optional: ['SENTRY_DSN'],
156
+ });
157
+
158
+ if (!result.ok) {
159
+ console.error('Missing:', result.missing);
160
+ process.exit(1);
161
+ }
162
+
163
+ console.log(result.config); // { PORT: '3000', API_KEY: '...' }
164
+ console.log(result.present); // ['PORT', 'API_KEY']
165
+ console.log(result.optionalMissing); // ['SENTRY_DSN']
166
+ ```
167
+
168
+ ### `PreflightError`
169
+
170
+ ```ts
171
+ import { preflight, PreflightError } from 'env-checklist';
172
+
173
+ try {
174
+ preflight(['PORT', 'API_KEY']);
175
+ } catch (e) {
176
+ if (e instanceof PreflightError) {
177
+ console.error('Missing keys:', e.missing); // ['API_KEY']
178
+ }
179
+ }
180
+ ```
181
+
182
+ ---
183
+
184
+ ## ๐Ÿค Contributing
185
+
186
+ Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/tangorishi/env-checklist).
187
+
188
+ 1. Fork the repo
189
+ 2. Create your branch: `git checkout -b usr/your-name`
190
+ 3. Make your changes and add tests
191
+ 4. Run `npm test` to verify
192
+ 5. Open a PR against `main`
193
+
194
+ ---
195
+
196
+ ## ๐Ÿ“„ License
197
+
198
+ MIT ยฉ [Rishi Joshi](https://github.com/tangorishi)
@@ -0,0 +1 @@
1
+ var f=class extends Error{missing;constructor(i){super(i.join(", ")),this.name="PreflightError",this.missing=i}};function u(n){let{required:i,optional:s=[]}=l(n),{missing:r,config:t}=a(i);for(let e of s){let o=process.env[e];o&&(t[e]=o)}if(r.length>0)throw new f(r);return t}function h(n){let{required:i,optional:s=[]}=l(n),{missing:r,present:t,config:e}=a(i),o=[],c=[];for(let g of s){let p=process.env[g];p?(e[g]=p,c.push(g)):o.push(g)}return{ok:r.length===0,config:e,missing:r,present:t,optionalMissing:o,optionalPresent:c}}function l(n){return Array.isArray(n)?{required:n,optional:[]}:{required:n.required,optional:n.optional??[]}}function a(n){let i=[],s=[],r={};for(let t of n){let e=process.env[t];e?(s.push(t),r[t]=e):i.push(t)}return{missing:i,present:s,config:r}}export{f as a,u as b,h as c};
package/dist/cli.cjs CHANGED
@@ -1,12 +1,36 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var d=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var y=(e,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of b(o))!x.call(e,s)&&s!==r&&a(e,s,{get:()=>o[s],enumerable:!(i=h(o,s))||i.enumerable});return e};var t=(e,o,r)=>(r=e!=null?d(u(e)):{},y(o||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e));var l=t(require("fs"),1),c=t(require("path"),1),n=t(require("chalk"),1),g=t(require("dotenv"),1);function f(e){let o=[],r={};for(let i of e){let s=process.env[i];s?r[i]=s:o.push(i)}return o.length>0&&(console.error(`
3
- \u2708\uFE0F [env-preflight] Missing variables: ${o.join(", ")}`),process.exit(1)),r}g.default.config();var m=process.cwd(),p=c.default.join(m,".env.example"),k=c.default.join(m,".env"),w=e=>console.log(`${n.default.cyan.bold("[env-checklist]")} ${e}`);l.default.existsSync(p)||(console.error(n.default.red.bold(`
4
- \u274C Error: No .env.example file found.`)),console.log(n.default.dim(`This tool requires a .env.example file to know what variables to check for.
5
- `)),process.exit(1));l.default.existsSync(k)||(console.warn(n.default.yellow.bold(`
6
- \u26A0\uFE0F Warning: No .env file found.`)),console.log(n.default.dim(`Create a .env file to satisfy the requirements in .env.example.
7
- `)));var C=l.default.readFileSync(p,"utf-8"),v=C.split(`
8
- `).map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).map(e=>e.split("=")[0].trim());v.length===0&&(w(n.default.yellow("No variables found in .env.example to validate.")),process.exit(0));console.log(n.default.blue.bold(`
9
- \u2708\uFE0F Checking environment variables...`));try{f(v),console.log(n.default.green.bold(`\u2705 All systems go. Environment is flight-ready.
10
- `))}catch(e){let o=e instanceof Error?e.message:String(e);console.error(n.default.red.bold(`
11
- \u274C Preflight Failed!`)),console.error(n.default.yellow(`Missing variables: ${o}`)),console.log(n.default.dim(`Please update your .env file to match .env.example.
2
+ "use strict";var O=Object.create;var w=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var L=(o,s,n,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let t of A(s))!j.call(o,t)&&t!==n&&w(o,t,{get:()=>s[t],enumerable:!(i=F(s,t))||i.enumerable});return o};var h=(o,s,n)=>(n=o!=null?O(M(o)):{},L(s||!o||!o.__esModule?w(n,"default",{value:o,enumerable:!0}):n,o));var g=h(require("fs"),1),u=h(require("path"),1),E=require("module"),e=h(require("chalk"),1),C=h(require("dotenv"),1);function P(o){let{required:s,optional:n=[]}=R(o),{missing:i,present:t,config:a}=T(s),f=[],b=[];for(let d of n){let $=process.env[d];$?(a[d]=$,b.push(d)):f.push(d)}return{ok:i.length===0,config:a,missing:i,present:t,optionalMissing:f,optionalPresent:b}}function R(o){return Array.isArray(o)?{required:o,optional:[]}:{required:o.required,optional:o.optional??[]}}function T(o){let s=[],n=[],i={};for(let t of o){let a=process.env[t];a?(n.push(t),i[t]=a):s.push(t)}return{missing:s,present:n,config:i}}var W={},r=process.argv.slice(2),y={fix:r.includes("--fix"),verbose:r.includes("--verbose"),help:r.includes("--help")||r.includes("-h"),version:r.includes("--version")||r.includes("-v")};if(y.version){let s=(0,E.createRequire)(W.url)("../package.json");console.log(`${e.default.cyan.bold("env-checklist")} ${e.default.white(`v${s.version}`)}`),process.exit(0)}var q=r.indexOf("--path"),m=q!==-1?r[q+1]:null;y.help&&(console.log(`
3
+ ${e.default.cyan.bold("\u2708\uFE0F env-checklist")} \u2014 preflight check for your environment variables
4
+
5
+ ${e.default.bold("Usage:")}
6
+ npx env-checklist [options]
7
+
8
+ ${e.default.bold("Options:")}
9
+ ${e.default.yellow("--verbose")} Show a status line for every key checked
10
+ ${e.default.yellow("--fix")} Auto-generate a .env file from .env.example (placeholder values)
11
+ ${e.default.yellow("--path <file>")} Use a custom .env.example path (useful in monorepos)
12
+ ${e.default.yellow("--version, -v")} Show the current version
13
+ ${e.default.yellow("--help, -h")} Show this help message
14
+
15
+ ${e.default.bold("Examples:")}
16
+ npx env-checklist
17
+ npx env-checklist --verbose
18
+ npx env-checklist --fix
19
+ npx env-checklist --path apps/api/.env.example
20
+ `),process.exit(0));var k=process.cwd(),v=m?u.default.resolve(k,m):u.default.join(k,".env.example"),x=u.default.join(k,".env");C.default.config({path:x});g.default.existsSync(v)||(console.error(e.default.red.bold(`
21
+ \u274C Error: No .env.example file found.`)),console.log(m?e.default.dim(` Looked at: ${v}
22
+ `):e.default.dim(` This tool requires a .env.example file to know what variables to check for.
23
+ `)),process.exit(1));var U=g.default.readFileSync(v,"utf-8"),N=U.split(`
24
+ `).map(o=>o.trim()),p=[],c=[];for(let o of N){if(!o||o.startsWith("#"))continue;let s=o.toLowerCase().includes("# optional"),n=o.split("=")[0].trim();n&&(s?c.push(n):p.push(n))}p.length===0&&c.length===0&&(console.log(e.default.yellow(`${e.default.cyan.bold("[env-checklist]")} No variables found in .env.example to validate.`)),process.exit(0));if(y.fix){g.default.existsSync(x)&&(console.log(e.default.yellow.bold(`
25
+ \u26A0\uFE0F .env already exists \u2014 skipping to avoid overwriting your values.`)),console.log(e.default.dim(` Delete your .env and re-run with --fix to regenerate.
26
+ `)),process.exit(0));let o=[...p,...c],s=["# Auto-generated by env-checklist --fix","# Fill in the values below before starting your app.","",...p.map(n=>`${n}=`),...c.length>0?["","# Optional",...c.map(n=>`${n}= # optional`)]:[]].join(`
27
+ `);g.default.writeFileSync(x,s,"utf-8"),console.log(e.default.green.bold(`
28
+ \u2705 .env file created from .env.example.`)),console.log(e.default.dim(` ${o.length} variable(s) scaffolded. Fill in the values before launching.
29
+ `)),process.exit(0)}g.default.existsSync(x)||(console.warn(e.default.yellow.bold(`
30
+ \u26A0\uFE0F Warning: No .env file found.`)),console.log(e.default.dim(` Run with --fix to auto-generate one, or create it manually.
31
+ `)));console.log(e.default.blue.bold(`
32
+ \u2708\uFE0F Checking environment variables...`));m&&console.log(e.default.dim(` Using: ${v}`));var l=P({required:p,optional:c});if(y.verbose){console.log("");let o=[...p.map(n=>({key:n,type:"required"})),...c.map(n=>({key:n,type:"optional"}))],s=Math.max(...o.map(n=>n.key.length),10);console.log(e.default.dim(" "+"KEY".padEnd(s+2)+"TYPE".padEnd(12)+"STATUS")),console.log(e.default.dim(" "+"\u2500".repeat(s+26)));for(let{key:n,type:i}of o){let a=(i==="required"?l.present.includes(n):l.optionalPresent.includes(n))?e.default.green("\u2705 present"):i==="optional"?e.default.dim("\u2796 not set"):e.default.red("\u274C missing"),f=i==="optional"?e.default.dim("optional"):e.default.white("required");console.log(` ${n.padEnd(s+2)}${f.padEnd(20)}${a}`)}console.log("")}var S=p.length+c.length,I=l.present.length+l.optionalPresent.length,K=l.missing.length;if(l.ok)console.log(e.default.green.bold("\u2705 All systems go. Environment is flight-ready.")),console.log(e.default.dim(` ${I}/${S} variable(s) present`)+(l.optionalMissing.length>0?e.default.dim(` \xB7 ${l.optionalMissing.length} optional not set`):"")),console.log("");else{console.error(e.default.red.bold(`
33
+ \u274C Preflight Failed!`)),console.log(""),console.log(e.default.red(" Missing required variables:"));for(let o of l.missing)console.log(` ${e.default.red("\u2716")} ${e.default.yellow(o)}`);console.log(""),console.log(e.default.dim(` ${l.present.length} passed \xB7 `)+e.default.red.bold(`${K} failed`)+e.default.dim(` \xB7 ${S} total`)),console.log(e.default.dim(`
34
+ Please update your .env file to match .env.example.
35
+ `)),console.log(e.default.dim(` Tip: run with --fix to auto-generate a .env scaffold.
12
36
  `)),process.exit(1)}
package/dist/cli.js CHANGED
@@ -1,11 +1,36 @@
1
1
  #!/usr/bin/env node
2
- import{a as r}from"./chunk-FEPVSWMN.js";import n from"fs";import l from"path";import o from"chalk";import c from"dotenv";c.config();var s=process.cwd(),t=l.join(s,".env.example"),m=l.join(s,".env"),f=e=>console.log(`${o.cyan.bold("[env-checklist]")} ${e}`);n.existsSync(t)||(console.error(o.red.bold(`
3
- \u274C Error: No .env.example file found.`)),console.log(o.dim(`This tool requires a .env.example file to know what variables to check for.
4
- `)),process.exit(1));n.existsSync(m)||(console.warn(o.yellow.bold(`
5
- \u26A0\uFE0F Warning: No .env file found.`)),console.log(o.dim(`Create a .env file to satisfy the requirements in .env.example.
6
- `)));var d=n.readFileSync(t,"utf-8"),i=d.split(`
7
- `).map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).map(e=>e.split("=")[0].trim());i.length===0&&(f(o.yellow("No variables found in .env.example to validate.")),process.exit(0));console.log(o.blue.bold(`
8
- \u2708\uFE0F Checking environment variables...`));try{r(i),console.log(o.green.bold(`\u2705 All systems go. Environment is flight-ready.
9
- `))}catch(e){let a=e instanceof Error?e.message:String(e);console.error(o.red.bold(`
10
- \u274C Preflight Failed!`)),console.error(o.yellow(`Missing variables: ${a}`)),console.log(o.dim(`Please update your .env file to match .env.example.
2
+ import{c as v}from"./chunk-RXQEM5JJ.js";import a from"fs";import f from"path";import{createRequire as k}from"module";import e from"chalk";import $ from"dotenv";var t=process.argv.slice(2),g={fix:t.includes("--fix"),verbose:t.includes("--verbose"),help:t.includes("--help")||t.includes("-h"),version:t.includes("--version")||t.includes("-v")};if(g.version){let s=k(import.meta.url)("../package.json");console.log(`${e.cyan.bold("env-checklist")} ${e.white(`v${s.version}`)}`),process.exit(0)}var u=t.indexOf("--path"),c=u!==-1?t[u+1]:null;g.help&&(console.log(`
3
+ ${e.cyan.bold("\u2708\uFE0F env-checklist")} \u2014 preflight check for your environment variables
4
+
5
+ ${e.bold("Usage:")}
6
+ npx env-checklist [options]
7
+
8
+ ${e.bold("Options:")}
9
+ ${e.yellow("--verbose")} Show a status line for every key checked
10
+ ${e.yellow("--fix")} Auto-generate a .env file from .env.example (placeholder values)
11
+ ${e.yellow("--path <file>")} Use a custom .env.example path (useful in monorepos)
12
+ ${e.yellow("--version, -v")} Show the current version
13
+ ${e.yellow("--help, -h")} Show this help message
14
+
15
+ ${e.bold("Examples:")}
16
+ npx env-checklist
17
+ npx env-checklist --verbose
18
+ npx env-checklist --fix
19
+ npx env-checklist --path apps/api/.env.example
20
+ `),process.exit(0));var m=process.cwd(),p=c?f.resolve(m,c):f.join(m,".env.example"),d=f.join(m,".env");$.config({path:d});a.existsSync(p)||(console.error(e.red.bold(`
21
+ \u274C Error: No .env.example file found.`)),console.log(c?e.dim(` Looked at: ${p}
22
+ `):e.dim(` This tool requires a .env.example file to know what variables to check for.
23
+ `)),process.exit(1));var w=a.readFileSync(p,"utf-8"),P=w.split(`
24
+ `).map(n=>n.trim()),r=[],i=[];for(let n of P){if(!n||n.startsWith("#"))continue;let s=n.toLowerCase().includes("# optional"),o=n.split("=")[0].trim();o&&(s?i.push(o):r.push(o))}r.length===0&&i.length===0&&(console.log(e.yellow(`${e.cyan.bold("[env-checklist]")} No variables found in .env.example to validate.`)),process.exit(0));if(g.fix){a.existsSync(d)&&(console.log(e.yellow.bold(`
25
+ \u26A0\uFE0F .env already exists \u2014 skipping to avoid overwriting your values.`)),console.log(e.dim(` Delete your .env and re-run with --fix to regenerate.
26
+ `)),process.exit(0));let n=[...r,...i],s=["# Auto-generated by env-checklist --fix","# Fill in the values below before starting your app.","",...r.map(o=>`${o}=`),...i.length>0?["","# Optional",...i.map(o=>`${o}= # optional`)]:[]].join(`
27
+ `);a.writeFileSync(d,s,"utf-8"),console.log(e.green.bold(`
28
+ \u2705 .env file created from .env.example.`)),console.log(e.dim(` ${n.length} variable(s) scaffolded. Fill in the values before launching.
29
+ `)),process.exit(0)}a.existsSync(d)||(console.warn(e.yellow.bold(`
30
+ \u26A0\uFE0F Warning: No .env file found.`)),console.log(e.dim(` Run with --fix to auto-generate one, or create it manually.
31
+ `)));console.log(e.blue.bold(`
32
+ \u2708\uFE0F Checking environment variables...`));c&&console.log(e.dim(` Using: ${p}`));var l=v({required:r,optional:i});if(g.verbose){console.log("");let n=[...r.map(o=>({key:o,type:"required"})),...i.map(o=>({key:o,type:"optional"}))],s=Math.max(...n.map(o=>o.key.length),10);console.log(e.dim(" "+"KEY".padEnd(s+2)+"TYPE".padEnd(12)+"STATUS")),console.log(e.dim(" "+"\u2500".repeat(s+26)));for(let{key:o,type:h}of n){let y=(h==="required"?l.present.includes(o):l.optionalPresent.includes(o))?e.green("\u2705 present"):h==="optional"?e.dim("\u2796 not set"):e.red("\u274C missing"),b=h==="optional"?e.dim("optional"):e.white("required");console.log(` ${o.padEnd(s+2)}${b.padEnd(20)}${y}`)}console.log("")}var x=r.length+i.length,S=l.present.length+l.optionalPresent.length,E=l.missing.length;if(l.ok)console.log(e.green.bold("\u2705 All systems go. Environment is flight-ready.")),console.log(e.dim(` ${S}/${x} variable(s) present`)+(l.optionalMissing.length>0?e.dim(` \xB7 ${l.optionalMissing.length} optional not set`):"")),console.log("");else{console.error(e.red.bold(`
33
+ \u274C Preflight Failed!`)),console.log(""),console.log(e.red(" Missing required variables:"));for(let n of l.missing)console.log(` ${e.red("\u2716")} ${e.yellow(n)}`);console.log(""),console.log(e.dim(` ${l.present.length} passed \xB7 `)+e.red.bold(`${E} failed`)+e.dim(` \xB7 ${x} total`)),console.log(e.dim(`
34
+ Please update your .env file to match .env.example.
35
+ `)),console.log(e.dim(` Tip: run with --fix to auto-generate a .env scaffold.
11
36
  `)),process.exit(1)}
package/dist/index.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";var r=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var c=(e,n)=>{for(var o in n)r(e,o,{get:n[o],enumerable:!0})},l=(e,n,o,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of g(n))!f.call(e,i)&&i!==o&&r(e,i,{get:()=>n[i],enumerable:!(s=t(n,i))||s.enumerable});return e};var p=e=>l(r({},"__esModule",{value:!0}),e);var u={};c(u,{preflight:()=>a});module.exports=p(u);function a(e){let n=[],o={};for(let s of e){let i=process.env[s];i?o[s]=i:n.push(s)}return n.length>0&&(console.error(`
2
- \u2708\uFE0F [env-preflight] Missing variables: ${n.join(", ")}`),process.exit(1)),o}0&&(module.exports={preflight});
1
+ "use strict";var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var m=(n,i)=>{for(var r in i)c(n,r,{get:i[r],enumerable:!0})},k=(n,i,r,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of d(i))!P.call(n,t)&&t!==r&&c(n,t,{get:()=>i[t],enumerable:!(e=h(i,t))||e.enumerable});return n};var q=n=>k(c({},"__esModule",{value:!0}),n);var v={};m(v,{PreflightError:()=>f,preflight:()=>x,preflightSafe:()=>y});module.exports=q(v);var f=class extends Error{missing;constructor(i){super(i.join(", ")),this.name="PreflightError",this.missing=i}};function x(n){let{required:i,optional:r=[]}=a(n),{missing:e,config:t}=u(i);for(let s of r){let o=process.env[s];o&&(t[s]=o)}if(e.length>0)throw new f(e);return t}function y(n){let{required:i,optional:r=[]}=a(n),{missing:e,present:t,config:s}=u(i),o=[],p=[];for(let g of r){let l=process.env[g];l?(s[g]=l,p.push(g)):o.push(g)}return{ok:e.length===0,config:s,missing:e,present:t,optionalMissing:o,optionalPresent:p}}function a(n){return Array.isArray(n)?{required:n,optional:[]}:{required:n.required,optional:n.optional??[]}}function u(n){let i=[],r=[],e={};for(let t of n){let s=process.env[t];s?(r.push(t),e[t]=s):i.push(t)}return{missing:i,present:r,config:e}}0&&(module.exports={PreflightError,preflight,preflightSafe});
package/dist/index.d.cts CHANGED
@@ -1,6 +1,23 @@
1
1
  interface Config {
2
- [key: string]: string | number | boolean;
2
+ [key: string]: string;
3
3
  }
4
- declare function preflight(requiredKeys: string[]): Config;
4
+ interface PreflightOptions {
5
+ required: string[];
6
+ optional?: string[];
7
+ }
8
+ interface PreflightSafeResult {
9
+ ok: boolean;
10
+ config: Config;
11
+ missing: string[];
12
+ present: string[];
13
+ optionalMissing: string[];
14
+ optionalPresent: string[];
15
+ }
16
+ declare class PreflightError extends Error {
17
+ readonly missing: string[];
18
+ constructor(missing: string[]);
19
+ }
20
+ declare function preflight(input: string[] | PreflightOptions): Config;
21
+ declare function preflightSafe(input: string[] | PreflightOptions): PreflightSafeResult;
5
22
 
6
- export { type Config, preflight };
23
+ export { type Config, PreflightError, type PreflightOptions, type PreflightSafeResult, preflight, preflightSafe };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,23 @@
1
1
  interface Config {
2
- [key: string]: string | number | boolean;
2
+ [key: string]: string;
3
3
  }
4
- declare function preflight(requiredKeys: string[]): Config;
4
+ interface PreflightOptions {
5
+ required: string[];
6
+ optional?: string[];
7
+ }
8
+ interface PreflightSafeResult {
9
+ ok: boolean;
10
+ config: Config;
11
+ missing: string[];
12
+ present: string[];
13
+ optionalMissing: string[];
14
+ optionalPresent: string[];
15
+ }
16
+ declare class PreflightError extends Error {
17
+ readonly missing: string[];
18
+ constructor(missing: string[]);
19
+ }
20
+ declare function preflight(input: string[] | PreflightOptions): Config;
21
+ declare function preflightSafe(input: string[] | PreflightOptions): PreflightSafeResult;
5
22
 
6
- export { type Config, preflight };
23
+ export { type Config, PreflightError, type PreflightOptions, type PreflightSafeResult, preflight, preflightSafe };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-FEPVSWMN.js";export{a as preflight};
1
+ import{a,b,c}from"./chunk-RXQEM5JJ.js";export{a as PreflightError,b as preflight,c as preflightSafe};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "env-checklist",
3
- "version": "1.1.2",
3
+ "version": "1.2.9",
4
4
  "description": "Ensure your environment variables are flight-ready before takeoff.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "bin": {
10
- "env-checklist": "./dist/cli.js"
10
+ "env-checklist": "dist/cli.js"
11
11
  },
12
12
  "files": [
13
13
  "dist"
@@ -16,7 +16,7 @@
16
16
  "start": "node ./dist/cli.js && node dist/index.js",
17
17
  "build": "tsup src/index.ts src/cli.ts --format cjs,esm --dts --clean --minify",
18
18
  "dev": "tsup src/index.ts --watch",
19
- "test": "vitest run",
19
+ "test": "vitest run --passWithNoTests",
20
20
  "lint": "tsc --noEmit"
21
21
  },
22
22
  "keywords": [
@@ -30,6 +30,10 @@
30
30
  ],
31
31
  "author": "Rishi Joshi",
32
32
  "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/tangorishi/env-checklist.git"
36
+ },
33
37
  "devDependencies": {
34
38
  "@types/node": "^20.11.0",
35
39
  "tsup": "^8.5.1",
@@ -40,4 +44,4 @@
40
44
  "chalk": "^5.3.0",
41
45
  "dotenv": "^16.4.5"
42
46
  }
43
- }
47
+ }
@@ -1,2 +0,0 @@
1
- function r(s){let n=[],i={};for(let e of s){let o=process.env[e];o?i[e]=o:n.push(e)}return n.length>0&&(console.error(`
2
- \u2708\uFE0F [env-preflight] Missing variables: ${n.join(", ")}`),process.exit(1)),i}export{r as a};