@zh-moody/safe-env 0.4.2 → 0.4.3
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/dist/chunk-3IILV4AU.js +9 -0
- package/dist/chunk-GHUSMNQT.cjs +1 -0
- package/dist/chunk-MTT5NLXM.cjs +9 -0
- package/dist/chunk-Z4SFK232.js +1 -0
- package/dist/fs-node.cjs +1 -1
- package/dist/fs-node.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{types-BsDPVktI.d.cts → types-DaBhCHE2.d.cts} +9 -2
- package/dist/{types-BsDPVktI.d.ts → types-DaBhCHE2.d.ts} +9 -2
- package/dist/vite.cjs +2 -2
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-5KPNMU6R.js +0 -1
- package/dist/chunk-6NHVLNFI.cjs +0 -9
- package/dist/chunk-JBML47XC.js +0 -9
- package/dist/chunk-TR6KYAQI.cjs +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var F="development",k="serve",M="build",S="VITE_DEV_SERVER",R="VITE_";var C=typeof window<"u"&&typeof window.document<"u";function m(n,o=!0){if(C)return`SafeEnv Validation Failed: ${n.map(t=>`${t.key} (${t.error})`).join(", ")}`;let c={r:"\x1B[31m",g:"\x1B[32m",y:"\x1B[33m",b:"\x1B[1m",res:"\x1B[0m",d:"\x1B[2m",cy:"\x1B[36m"},e=(t,p)=>{let l=String(t),b=()=>{let s=0;for(let h of l){let u=h.codePointAt(0)??0;s+=u>255||u>=126976&&u<=131071?2:1}return s};for(;b()>p;)l=l.slice(0,-1);return l+" ".repeat(p-b())},i=Math.max(80,(typeof process<"u"?process.stdout.columns:80)||80)-10,x=Math.floor(i*.3),v=Math.floor(i*.5),r=o?c:{r:"",g:"",y:"",b:"",res:"",d:"",cy:""},d=`
|
|
2
|
+
${r.r}${r.b}\u274C SafeEnv Validation Failed${r.res}
|
|
3
|
+
`;return d+=` ${r.b}${e("Key",x)} \u2502 ${e("Error",v)} \u2502 Value${r.res}
|
|
4
|
+
`,d+=r.d+"\u2500".repeat(i+5)+r.res+`
|
|
5
|
+
`,n.forEach(t=>{let p=t.value===void 0?"undefined":t.isSecret?"********":`"${t.value}"`,l=t.value===void 0?r.d:t.isSecret?r.y:r.cy;d+=` ${r.y}${e(t.key,x)}${r.res} \u2502 ${r.r}${e(t.error,v)}${r.res} \u2502 ${l}${p}${r.res}
|
|
6
|
+
`}),d+=r.d+"\u2500".repeat(i+5)+r.res+`
|
|
7
|
+
`,d+=` ${r.g}\u{1F4A1} Tip: Check your .env files or schema definitions.${r.res}
|
|
8
|
+
`,d}function _(n){if(C){console.group("%c \u274C SafeEnv Validation Failed ","background: #fee2e2; color: #b91c1c; font-weight: bold; padding: 4px; border-radius: 2px;");let o=n.reduce((c,e)=>(c[e.key]={"Error Message":e.error,"Current Value":e.value===void 0?"undefined":e.isSecret?"********":e.value},c),{});console.table(o),console.log("%c \u{1F4A1} Tip: Check your .env files or schema definitions. ","color: #059669; font-style: italic;"),console.groupEnd()}else console.error(m(n,!0))}var y={},T=new WeakMap;function P(n){let o=m(n,!1);return new Proxy({},{get(c,e){if(e==="__isSafeEnvError")return!0;if(e==="toJSON")return()=>({error:"SafeEnv Validation Failed"});throw new Error(`[safe-env] Cannot access "${String(e)}" because validation failed:
|
|
9
|
+
${o}`)},ownKeys(){return[]},getOwnPropertyDescriptor(){}})}var w="[safe-env] Cannot modify read-only environment variables.";function O(n){if(T.has(n))return T.get(n);let o=new Proxy(n,{get(c,e){if(e==="__isSafeEnv")return!0;let i=Reflect.get(c,e);return i!==null&&typeof i=="object"&&!Object.isFrozen(i)?O(i):i},set(){throw new Error(w)},deleteProperty(){throw new Error(w)},defineProperty(){throw new Error(w)},setPrototypeOf(){throw new Error(w)}});return T.set(n,o),o}function I(n,o,c,e){return o||(c[n]!==void 0?n:e&&!n.startsWith(e)?e+n:n)}function W(n,o={}){let{loadProcessEnv:c=!0,prefix:e=R,cwd:i,useCache:x=!0,refreshCache:v=!1,envLoader:r}=o,d=o.mode||(typeof process<"u"?process.env.NODE_ENV:void 0)||F,t=`${e}|${i??""}|${d}`;v&&delete y[t];let p=typeof window<"u",l=typeof process<"u"&&(!!process.env.VITE||!!process.env[S]),b=p||l||"source"in o,s={},h=!1;if("source"in o)o.source===void 0?(h=!0,s={}):s=o.source;else if(x&&!v&&y[t]&&Object.keys(y[t]).length>0)s=y[t];else if(typeof process<"u"&&!p)try{let a={};if(r)for(let f of[".env",`.env.${d}`,".env.local",`.env.${d}.local`])a={...a,...r(f,i)};s={...a,...c?process.env:{}}}catch{s={}}x&&Object.keys(s).length>0&&(y[t]||(y[t]={}),Object.assign(y[t],s));let u={},E=[];for(let a in n){let f=n[a],V=I(a,f.sourceKey,s,e),g=s[V],$={source:s,parsed:u};try{let D=typeof f.required=="function"?f.required($):f.required;if(g===void 0||g===""&&f.default!==void 0){if(D&&g===void 0)throw new Error("Missing required field");u[a]=f.default}else u[a]=f.parse(g,$)}catch(D){E.push({key:V,error:D.message,value:g,isSecret:f.metadata?.isSecret})}}if(E.length>0){if(o.throwOnError){let a=new Error(m(E,!0));throw a.plainMessage=m(E,!1),a}return h||_(E),typeof process<"u"&&process.exit&&!b&&process.exit(1),P(E)}return O(u)}export{F as a,k as b,M as c,S as d,R as e,m as f,_ as g,W as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);var _path = require('path'); var _path2 = _interopRequireDefault(_path);function g(t,i){let n="",r=1;for(;r<t.length;){if(t[r]==="\\"&&r+1<t.length){n+=t[r+1],r+=2;continue}if(t[r]===i)return n;n+=t[r++]}return null}function m(t){let i={},n=t.split(/\r?\n/);for(let r of n){let o=r.trim();if(!o||o.startsWith("#"))continue;let s=o.indexOf("=");if(s===-1)continue;let c=o.slice(0,s).trim(),e=o.slice(s+1).trim();if(!e){i[c]="";continue}let f=e[0];if(f==='"'||f==="'"){let u=g(e,f);if(u!==null){i[c]=u;continue}}let l=e.indexOf("#");l!==-1&&(e=e.slice(0,l).trim()),i[c]=e}return i}function D(t=".env",i){try{let n=_path2.default.resolve(i||process.cwd(),t);if(_fs2.default.existsSync(n))return m(_fs2.default.readFileSync(n,"utf-8"))}catch (e2){}return{}}exports.a = m; exports.b = D;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var F="development",k= exports.b ="serve",M= exports.c ="build",S= exports.d ="VITE_DEV_SERVER",R= exports.e ="VITE_";var C=typeof window<"u"&&typeof window.document<"u";function m(n,o=!0){if(C)return`SafeEnv Validation Failed: ${n.map(t=>`${t.key} (${t.error})`).join(", ")}`;let c={r:"\x1B[31m",g:"\x1B[32m",y:"\x1B[33m",b:"\x1B[1m",res:"\x1B[0m",d:"\x1B[2m",cy:"\x1B[36m"},e=(t,p)=>{let l=String(t),b=()=>{let s=0;for(let h of l){let u=_nullishCoalesce(h.codePointAt(0), () => (0));s+=u>255||u>=126976&&u<=131071?2:1}return s};for(;b()>p;)l=l.slice(0,-1);return l+" ".repeat(p-b())},i=Math.max(80,(typeof process<"u"?process.stdout.columns:80)||80)-10,x=Math.floor(i*.3),v=Math.floor(i*.5),r=o?c:{r:"",g:"",y:"",b:"",res:"",d:"",cy:""},d=`
|
|
2
|
+
${r.r}${r.b}\u274C SafeEnv Validation Failed${r.res}
|
|
3
|
+
`;return d+=` ${r.b}${e("Key",x)} \u2502 ${e("Error",v)} \u2502 Value${r.res}
|
|
4
|
+
`,d+=r.d+"\u2500".repeat(i+5)+r.res+`
|
|
5
|
+
`,n.forEach(t=>{let p=t.value===void 0?"undefined":t.isSecret?"********":`"${t.value}"`,l=t.value===void 0?r.d:t.isSecret?r.y:r.cy;d+=` ${r.y}${e(t.key,x)}${r.res} \u2502 ${r.r}${e(t.error,v)}${r.res} \u2502 ${l}${p}${r.res}
|
|
6
|
+
`}),d+=r.d+"\u2500".repeat(i+5)+r.res+`
|
|
7
|
+
`,d+=` ${r.g}\u{1F4A1} Tip: Check your .env files or schema definitions.${r.res}
|
|
8
|
+
`,d}function _(n){if(C){console.group("%c \u274C SafeEnv Validation Failed ","background: #fee2e2; color: #b91c1c; font-weight: bold; padding: 4px; border-radius: 2px;");let o=n.reduce((c,e)=>(c[e.key]={"Error Message":e.error,"Current Value":e.value===void 0?"undefined":e.isSecret?"********":e.value},c),{});console.table(o),console.log("%c \u{1F4A1} Tip: Check your .env files or schema definitions. ","color: #059669; font-style: italic;"),console.groupEnd()}else console.error(m(n,!0))}var y={},T=new WeakMap;function P(n){let o=m(n,!1);return new Proxy({},{get(c,e){if(e==="__isSafeEnvError")return!0;if(e==="toJSON")return()=>({error:"SafeEnv Validation Failed"});throw new Error(`[safe-env] Cannot access "${String(e)}" because validation failed:
|
|
9
|
+
${o}`)},ownKeys(){return[]},getOwnPropertyDescriptor(){}})}var w="[safe-env] Cannot modify read-only environment variables.";function O(n){if(T.has(n))return T.get(n);let o=new Proxy(n,{get(c,e){if(e==="__isSafeEnv")return!0;let i=Reflect.get(c,e);return i!==null&&typeof i=="object"&&!Object.isFrozen(i)?O(i):i},set(){throw new Error(w)},deleteProperty(){throw new Error(w)},defineProperty(){throw new Error(w)},setPrototypeOf(){throw new Error(w)}});return T.set(n,o),o}function I(n,o,c,e){return o||(c[n]!==void 0?n:e&&!n.startsWith(e)?e+n:n)}function W(n,o={}){let{loadProcessEnv:c=!0,prefix:e=R,cwd:i,useCache:x=!0,refreshCache:v=!1,envLoader:r}=o,d=o.mode||(typeof process<"u"?process.env.NODE_ENV:void 0)||F,t=`${e}|${_nullishCoalesce(i, () => (""))}|${d}`;v&&delete y[t];let p=typeof window<"u",l=typeof process<"u"&&(!!process.env.VITE||!!process.env[S]),b=p||l||"source"in o,s={},h=!1;if("source"in o)o.source===void 0?(h=!0,s={}):s=o.source;else if(x&&!v&&y[t]&&Object.keys(y[t]).length>0)s=y[t];else if(typeof process<"u"&&!p)try{let a={};if(r)for(let f of[".env",`.env.${d}`,".env.local",`.env.${d}.local`])a={...a,...r(f,i)};s={...a,...c?process.env:{}}}catch (e2){s={}}x&&Object.keys(s).length>0&&(y[t]||(y[t]={}),Object.assign(y[t],s));let u={},E=[];for(let a in n){let f=n[a],V=I(a,f.sourceKey,s,e),g=s[V],$={source:s,parsed:u};try{let D=typeof f.required=="function"?f.required($):f.required;if(g===void 0||g===""&&f.default!==void 0){if(D&&g===void 0)throw new Error("Missing required field");u[a]=f.default}else u[a]=f.parse(g,$)}catch(D){E.push({key:V,error:D.message,value:g,isSecret:_optionalChain([f, 'access', _2 => _2.metadata, 'optionalAccess', _3 => _3.isSecret])})}}if(E.length>0){if(o.throwOnError){let a=new Error(m(E,!0));throw a.plainMessage=m(E,!1),a}return h||_(E),typeof process<"u"&&process.exit&&!b&&process.exit(1),P(E)}return O(u)}exports.a = F; exports.b = k; exports.c = M; exports.d = S; exports.e = R; exports.f = m; exports.g = _; exports.h = W;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import d from"fs";import p from"path";function g(t,i){let n="",r=1;for(;r<t.length;){if(t[r]==="\\"&&r+1<t.length){n+=t[r+1],r+=2;continue}if(t[r]===i)return n;n+=t[r++]}return null}function m(t){let i={},n=t.split(/\r?\n/);for(let r of n){let o=r.trim();if(!o||o.startsWith("#"))continue;let s=o.indexOf("=");if(s===-1)continue;let c=o.slice(0,s).trim(),e=o.slice(s+1).trim();if(!e){i[c]="";continue}let f=e[0];if(f==='"'||f==="'"){let u=g(e,f);if(u!==null){i[c]=u;continue}}let l=e.indexOf("#");l!==-1&&(e=e.slice(0,l).trim()),i[c]=e}return i}function D(t=".env",i){try{let n=p.resolve(i||process.cwd(),t);if(d.existsSync(n))return m(d.readFileSync(n,"utf-8"))}catch{}return{}}export{m as a,D as b};
|
package/dist/fs-node.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGHUSMNQTcjs = require('./chunk-GHUSMNQT.cjs');exports.loadDotEnv = _chunkGHUSMNQTcjs.b;
|
package/dist/fs-node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"./chunk-
|
|
1
|
+
import{b as a}from"./chunk-Z4SFK232.js";export{a as loadDotEnv};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkGHUSMNQTcjs = require('./chunk-GHUSMNQT.cjs');var _chunkMTT5NLXMcjs = require('./chunk-MTT5NLXM.cjs');var a=class{constructor(e,n,r,i=[]){this.type=e,this.default=n,this.required=n===void 0,this.parse=r,this.metadata=i.length?{options:i}:{}}from(e){return this.sourceKey=e,this}optional(){return this.required=!1,this}requiredIf(e){return this.required=e,this}validate(e,n="Custom validation failed"){let r=this.parse;return this.parse=(i,o)=>{let s=r(i,o);if(!e(s,o))throw new Error(n);return s},this}min(e){let n=this.parse;return this.parse=(r,i)=>{let o=n(r,i);if(typeof o=="number"&&o<e)throw new Error(`Below min ${e}`);return o},this.metadata={...this.metadata,min:e},this}max(e){let n=this.parse;return this.parse=(r,i)=>{let o=n(r,i);if(typeof o=="number"&&o>e)throw new Error(`Above max ${e}`);return o},this.metadata={...this.metadata,max:e},this}transform(e){let n=this.parse;return this.parse=(r,i)=>e(n(r,i),i),this}secret(){return this.metadata={...this.metadata,isSecret:!0},this}description(e){return this.metadata={...this.metadata,description:e},this}},m= exports.s ={string:t=>new a("string",t,e=>String(e)),number:t=>new a("number",t,e=>{let n=Number(e);if(isNaN(n))throw new Error(`Invalid number value: "${e}"`);return n}),boolean:t=>new a("boolean",t,e=>{if(typeof e=="boolean")return e;if(e==="")return!1;let n=String(e).toLowerCase().trim();if(["true","1","yes","on"].includes(n))return!0;if(["false","0","no","off"].includes(n))return!1;throw new Error(`Invalid boolean value: "${e}"`)}),enum:(t,e)=>new a("enum",e,n=>{if(!t.includes(n))throw new Error(`Value "${n}" is not one of: ${t.join(", ")}`);return n},t),array:(t,e=",")=>new a("array",t,n=>{if(!e)throw new Error("[safe-env] array separator cannot be empty");return Array.isArray(n)?n:typeof n!="string"?[]:n.split(e).map(r=>r.trim()).filter(Boolean)})};var b=t=>{try{return new URL(String(t)),!0}catch (e2){return!1}},D= exports.isEmail =t=>/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(String(t)),S= exports.matchesRegex =t=>e=>t.test(String(e)),T= exports.isIPv4 =t=>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(String(t)),E= exports.isUUID =t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(String(t)),F= exports.isBase64 =t=>/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(String(t)),C= exports.isJSON =t=>{try{return JSON.parse(String(t)),!0}catch (e3){return!1}},N= exports.isHexColor =t=>/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/.test(String(t)),$= exports.isObjectId =t=>/^[0-9a-fA-F]{24}$/.test(String(t)),V= exports.trim =t=>String(t).trim(),v= exports.toLowerCase =t=>String(t).toLowerCase(),k= exports.toUpperCase =t=>String(t).toUpperCase(),A= exports.toJSON =t=>{try{return JSON.parse(String(t))}catch (e4){throw new Error("Invalid JSON string")}};function B(t,e={}){let n=typeof process<"u"&&(_optionalChain([process, 'access', _ => _.release, 'optionalAccess', _2 => _2.name])==="node"||!!_optionalChain([process, 'access', _3 => _3.versions, 'optionalAccess', _4 => _4.node]));return _chunkMTT5NLXMcjs.h.call(void 0, t,{...e,envLoader:n?_chunkGHUSMNQTcjs.b:void 0})}exports.BUILD = _chunkMTT5NLXMcjs.c; exports.DEV = _chunkMTT5NLXMcjs.a; exports.SERVE = _chunkMTT5NLXMcjs.b; exports.VITE_DEV_FLAG = _chunkMTT5NLXMcjs.d; exports.VITE_PREFIX = _chunkMTT5NLXMcjs.e; exports.formatErrorReport = _chunkMTT5NLXMcjs.f; exports.isBase64 = F; exports.isEmail = D; exports.isHexColor = N; exports.isIPv4 = T; exports.isJSON = C; exports.isObjectId = $; exports.isUUID = E; exports.isUrl = b; exports.matchesRegex = S; exports.parseDotEnv = _chunkGHUSMNQTcjs.a; exports.reportErrors = _chunkMTT5NLXMcjs.g; exports.s = m; exports.safeEnv = B; exports.toJSON = A; exports.toLowerCase = v; exports.toUpperCase = k; exports.trim = V;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldDefinition, E as EnvError, S as Schema, a as SafeEnvOptions, I as InferSchema } from './types-
|
|
2
|
-
export { B as BUILD, b as BaseType, D as DEV, c as SERVE, V as VITE_DEV_FLAG,
|
|
1
|
+
import { F as FieldDefinition, E as EnvError, S as Schema, a as SafeEnvOptions, I as InferSchema } from './types-DaBhCHE2.cjs';
|
|
2
|
+
export { B as BUILD, b as BaseType, D as DEV, c as FieldMetadata, d as SERVE, V as VITE_DEV_FLAG, e as VITE_PREFIX, f as ValidationContext } from './types-DaBhCHE2.cjs';
|
|
3
3
|
|
|
4
4
|
declare const s: {
|
|
5
5
|
string: (d?: string) => FieldDefinition<string>;
|
|
@@ -25,7 +25,7 @@ declare const toJSON: (v: string) => any;
|
|
|
25
25
|
|
|
26
26
|
/***
|
|
27
27
|
* 将 .env 内容字符串解析为对象
|
|
28
|
-
*
|
|
28
|
+
* 兼容带引号的值、转义字符(\"、\')、以及行尾注释
|
|
29
29
|
*/
|
|
30
30
|
declare function parseDotEnv(content: string): Record<string, string>;
|
|
31
31
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldDefinition, E as EnvError, S as Schema, a as SafeEnvOptions, I as InferSchema } from './types-
|
|
2
|
-
export { B as BUILD, b as BaseType, D as DEV, c as SERVE, V as VITE_DEV_FLAG,
|
|
1
|
+
import { F as FieldDefinition, E as EnvError, S as Schema, a as SafeEnvOptions, I as InferSchema } from './types-DaBhCHE2.js';
|
|
2
|
+
export { B as BUILD, b as BaseType, D as DEV, c as FieldMetadata, d as SERVE, V as VITE_DEV_FLAG, e as VITE_PREFIX, f as ValidationContext } from './types-DaBhCHE2.js';
|
|
3
3
|
|
|
4
4
|
declare const s: {
|
|
5
5
|
string: (d?: string) => FieldDefinition<string>;
|
|
@@ -25,7 +25,7 @@ declare const toJSON: (v: string) => any;
|
|
|
25
25
|
|
|
26
26
|
/***
|
|
27
27
|
* 将 .env 内容字符串解析为对象
|
|
28
|
-
*
|
|
28
|
+
* 兼容带引号的值、转义字符(\"、\')、以及行尾注释
|
|
29
29
|
*/
|
|
30
30
|
declare function parseDotEnv(content: string): Record<string, string>;
|
|
31
31
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as d,b as l}from"./chunk-Z4SFK232.js";import{a as c,b as h,c as g,d as x,e as w,f as u,g as p,h as f}from"./chunk-3IILV4AU.js";var a=class{type;default;required;sourceKey;metadata;parse;constructor(e,n,r,i=[]){this.type=e,this.default=n,this.required=n===void 0,this.parse=r,this.metadata=i.length?{options:i}:{}}from(e){return this.sourceKey=e,this}optional(){return this.required=!1,this}requiredIf(e){return this.required=e,this}validate(e,n="Custom validation failed"){let r=this.parse;return this.parse=(i,o)=>{let s=r(i,o);if(!e(s,o))throw new Error(n);return s},this}min(e){let n=this.parse;return this.parse=(r,i)=>{let o=n(r,i);if(typeof o=="number"&&o<e)throw new Error(`Below min ${e}`);return o},this.metadata={...this.metadata,min:e},this}max(e){let n=this.parse;return this.parse=(r,i)=>{let o=n(r,i);if(typeof o=="number"&&o>e)throw new Error(`Above max ${e}`);return o},this.metadata={...this.metadata,max:e},this}transform(e){let n=this.parse;return this.parse=(r,i)=>e(n(r,i),i),this}secret(){return this.metadata={...this.metadata,isSecret:!0},this}description(e){return this.metadata={...this.metadata,description:e},this}},m={string:t=>new a("string",t,e=>String(e)),number:t=>new a("number",t,e=>{let n=Number(e);if(isNaN(n))throw new Error(`Invalid number value: "${e}"`);return n}),boolean:t=>new a("boolean",t,e=>{if(typeof e=="boolean")return e;if(e==="")return!1;let n=String(e).toLowerCase().trim();if(["true","1","yes","on"].includes(n))return!0;if(["false","0","no","off"].includes(n))return!1;throw new Error(`Invalid boolean value: "${e}"`)}),enum:(t,e)=>new a("enum",e,n=>{if(!t.includes(n))throw new Error(`Value "${n}" is not one of: ${t.join(", ")}`);return n},t),array:(t,e=",")=>new a("array",t,n=>{if(!e)throw new Error("[safe-env] array separator cannot be empty");return Array.isArray(n)?n:typeof n!="string"?[]:n.split(e).map(r=>r.trim()).filter(Boolean)})};var b=t=>{try{return new URL(String(t)),!0}catch{return!1}},D=t=>/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(String(t)),S=t=>e=>t.test(String(e)),T=t=>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(String(t)),E=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(String(t)),F=t=>/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(String(t)),C=t=>{try{return JSON.parse(String(t)),!0}catch{return!1}},N=t=>/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/.test(String(t)),$=t=>/^[0-9a-fA-F]{24}$/.test(String(t)),V=t=>String(t).trim(),v=t=>String(t).toLowerCase(),k=t=>String(t).toUpperCase(),A=t=>{try{return JSON.parse(String(t))}catch{throw new Error("Invalid JSON string")}};function B(t,e={}){let n=typeof process<"u"&&(process.release?.name==="node"||!!process.versions?.node);return f(t,{...e,envLoader:n?l:void 0})}export{g as BUILD,c as DEV,h as SERVE,x as VITE_DEV_FLAG,w as VITE_PREFIX,u as formatErrorReport,F as isBase64,D as isEmail,N as isHexColor,T as isIPv4,C as isJSON,$ as isObjectId,E as isUUID,b as isUrl,S as matchesRegex,d as parseDotEnv,p as reportErrors,m as s,B as safeEnv,A as toJSON,v as toLowerCase,k as toUpperCase,V as trim};
|
|
@@ -8,12 +8,19 @@ interface ValidationContext {
|
|
|
8
8
|
source: Record<string, any>;
|
|
9
9
|
parsed: Record<string, any>;
|
|
10
10
|
}
|
|
11
|
+
interface FieldMetadata {
|
|
12
|
+
isSecret?: boolean;
|
|
13
|
+
description?: string;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
options?: string[];
|
|
17
|
+
}
|
|
11
18
|
interface FieldDefinition<T = any, D extends string = string> {
|
|
12
19
|
type: BaseType;
|
|
13
20
|
default?: T;
|
|
14
21
|
required: boolean | ((ctx: ValidationContext) => boolean);
|
|
15
22
|
sourceKey?: string;
|
|
16
|
-
metadata?:
|
|
23
|
+
metadata?: FieldMetadata;
|
|
17
24
|
parse: (val: any, ctx: ValidationContext) => T;
|
|
18
25
|
from: (key: string) => FieldDefinition<T, D>;
|
|
19
26
|
optional: () => FieldDefinition<T | undefined, D>;
|
|
@@ -47,4 +54,4 @@ interface SafeEnvOptions {
|
|
|
47
54
|
/** @internal */ devMode?: boolean;
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
export { BUILD as B, DEV as D, type EnvError as E, type FieldDefinition as F, type InferSchema as I, type Schema as S, VITE_DEV_FLAG as V, type SafeEnvOptions as a, type BaseType as b,
|
|
57
|
+
export { BUILD as B, DEV as D, type EnvError as E, type FieldDefinition as F, type InferSchema as I, type Schema as S, VITE_DEV_FLAG as V, type SafeEnvOptions as a, type BaseType as b, type FieldMetadata as c, SERVE as d, VITE_PREFIX as e, type ValidationContext as f };
|
|
@@ -8,12 +8,19 @@ interface ValidationContext {
|
|
|
8
8
|
source: Record<string, any>;
|
|
9
9
|
parsed: Record<string, any>;
|
|
10
10
|
}
|
|
11
|
+
interface FieldMetadata {
|
|
12
|
+
isSecret?: boolean;
|
|
13
|
+
description?: string;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
options?: string[];
|
|
17
|
+
}
|
|
11
18
|
interface FieldDefinition<T = any, D extends string = string> {
|
|
12
19
|
type: BaseType;
|
|
13
20
|
default?: T;
|
|
14
21
|
required: boolean | ((ctx: ValidationContext) => boolean);
|
|
15
22
|
sourceKey?: string;
|
|
16
|
-
metadata?:
|
|
23
|
+
metadata?: FieldMetadata;
|
|
17
24
|
parse: (val: any, ctx: ValidationContext) => T;
|
|
18
25
|
from: (key: string) => FieldDefinition<T, D>;
|
|
19
26
|
optional: () => FieldDefinition<T | undefined, D>;
|
|
@@ -47,4 +54,4 @@ interface SafeEnvOptions {
|
|
|
47
54
|
/** @internal */ devMode?: boolean;
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
export { BUILD as B, DEV as D, type EnvError as E, type FieldDefinition as F, type InferSchema as I, type Schema as S, VITE_DEV_FLAG as V, type SafeEnvOptions as a, type BaseType as b,
|
|
57
|
+
export { BUILD as B, DEV as D, type EnvError as E, type FieldDefinition as F, type InferSchema as I, type Schema as S, VITE_DEV_FLAG as V, type SafeEnvOptions as a, type BaseType as b, type FieldMetadata as c, SERVE as d, VITE_PREFIX as e, type ValidationContext as f };
|
package/dist/vite.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
`),process.exit(1))}},transform(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMTT5NLXMcjs = require('./chunk-MTT5NLXM.cjs');var _vite = require('vite');function g(v,c={}){let n=null,s=!1;return{name:"vite-plugin-safe-env",configResolved(e){s=e.command===_chunkMTT5NLXMcjs.b,process.env[_chunkMTT5NLXMcjs.d]=s?"true":"";let{envDir:o=e.root,prefix:r=e.envPrefix||_chunkMTT5NLXMcjs.e}=c,t=_vite.loadEnv.call(void 0, e.mode,o,r);try{_chunkMTT5NLXMcjs.h.call(void 0, v,{source:t,prefix:Array.isArray(r)?r[0]:r,loadProcessEnv:!1,throwOnError:!0}),n=null}catch(l){n=l,s?e.logger.error(l.message):(console.error(l.message),console.error(`\x1B[31m[safe-env] Fatal: Environment validation failed during build. Exiting...\x1B[0m
|
|
2
|
+
`),process.exit(1))}},transform(e,o){if(!s||!n||o.includes("node_modules")||o.endsWith(".d.ts"))return null;let r=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,"");if(r.includes("import.meta.env")||r.includes("safeEnv")){let t=new Error(n.plainMessage||n.message);throw t.stack="",t}return null}}}exports.viteSafeEnv = g;
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,d as i,e as
|
|
2
|
-
`),process.exit(1))}},transform(e,
|
|
1
|
+
import{b as a,d as i,e as m,h as u}from"./chunk-3IILV4AU.js";import{loadEnv as f}from"vite";function g(v,c={}){let n=null,s=!1;return{name:"vite-plugin-safe-env",configResolved(e){s=e.command===a,process.env[i]=s?"true":"";let{envDir:o=e.root,prefix:r=e.envPrefix||m}=c,t=f(e.mode,o,r);try{u(v,{source:t,prefix:Array.isArray(r)?r[0]:r,loadProcessEnv:!1,throwOnError:!0}),n=null}catch(l){n=l,s?e.logger.error(l.message):(console.error(l.message),console.error(`\x1B[31m[safe-env] Fatal: Environment validation failed during build. Exiting...\x1B[0m
|
|
2
|
+
`),process.exit(1))}},transform(e,o){if(!s||!n||o.includes("node_modules")||o.endsWith(".d.ts"))return null;let r=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,"");if(r.includes("import.meta.env")||r.includes("safeEnv")){let t=new Error(n.plainMessage||n.message);throw t.stack="",t}return null}}}export{g as viteSafeEnv};
|
package/package.json
CHANGED
package/dist/chunk-5KPNMU6R.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import u from"fs";import a from"path";function m(r){let n={},i=r.split(/\r?\n/);for(let d of i){let e=d.trim();if(!e||e.startsWith("#"))continue;let o=e.indexOf("=");if(o===-1)continue;let s=e.slice(0,o).trim(),t=e.slice(o+1).trim();if(!t){n[s]="";continue}let c=t[0];if(c==='"'||c==="'"){let l=t.indexOf(c,1);if(l!==-1){n[s]=t.slice(1,l);continue}}let f=t.indexOf("#");f!==-1&&(t=t.slice(0,f).trim()),n[s]=t}return n}function h(r=".env",n){try{let i=a.resolve(n||process.cwd(),r);if(u.existsSync(i))return m(u.readFileSync(i,"utf-8"))}catch{}return{}}export{m as a,h as b};
|
package/dist/chunk-6NHVLNFI.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var F="development",j= exports.b ="serve",K= exports.c ="build",C= exports.d ="VITE_DEV_SERVER",k= exports.e ="VITE_";var O=typeof window<"u"&&typeof window.document<"u";function b(i,o=!0){if(O)return`SafeEnv Validation Failed: ${i.map(s=>`${s.key} (${s.error})`).join(", ")}`;let d={r:"\x1B[31m",g:"\x1B[32m",y:"\x1B[33m",b:"\x1B[1m",res:"\x1B[0m",d:"\x1B[2m",cy:"\x1B[36m"},n=(s,p)=>{let r=String(s),x=()=>r.length+(r.match(/[^\x00-\xff]/g)||[]).length;for(;x()>p;)r=r.slice(0,-1);return r+" ".repeat(p-x())},c=Math.max(80,(typeof process<"u"?process.stdout.columns:80)||80)-10,u=Math.floor(c*.3),y=Math.floor(c*.5),e=o?d:{r:"",g:"",y:"",b:"",res:"",d:"",cy:""},f=`
|
|
2
|
-
${e.r}${e.b}\u274C SafeEnv Validation Failed${e.res}
|
|
3
|
-
`;return f+=` ${e.b}${n("Key",u)} \u2502 ${n("Error",y)} \u2502 Value${e.res}
|
|
4
|
-
`,f+=e.d+"\u2500".repeat(c+5)+e.res+`
|
|
5
|
-
`,i.forEach(s=>{let p=s.value===void 0?"undefined":s.isSecret?"********":`"${s.value}"`,r=s.value===void 0?e.d:s.isSecret?e.y:e.cy;f+=` ${e.y}${n(s.key,u)}${e.res} \u2502 ${e.r}${n(s.error,y)}${e.res} \u2502 ${r}${p}${e.res}
|
|
6
|
-
`}),f+=e.d+"\u2500".repeat(c+5)+e.res+`
|
|
7
|
-
`,f+=` ${e.g}\u{1F4A1} Tip: Check your .env files or schema definitions.${e.res}
|
|
8
|
-
`,f}function _(i){if(O){console.group("%c \u274C SafeEnv Validation Failed ","background: #fee2e2; color: #b91c1c; font-weight: bold; padding: 4px; border-radius: 2px;");let o=i.reduce((d,n)=>(d[n.key]={"Error Message":n.error,"Current Value":n.value===void 0?"undefined":n.isSecret?"********":n.value},d),{});console.table(o),console.log("%c \u{1F4A1} Tip: Check your .env files or schema definitions. ","color: #059669; font-style: italic;"),console.groupEnd()}else console.error(b(i,!0))}var l={},$=new WeakMap;function P(i){let o=b(i,!1);return new Proxy({},{get(d,n){if(n==="__isSafeEnvError")return!0;if(n==="toJSON")return()=>({error:"SafeEnv Validation Failed"});throw new Error(`[safe-env] Cannot access "${String(n)}" because validation failed:
|
|
9
|
-
${o}`)},ownKeys(){return[]},getOwnPropertyDescriptor(){}})}var w="[safe-env] Cannot modify read-only environment variables.";function I(i){if($.has(i))return $.get(i);let o=new Proxy(i,{get(d,n){if(n==="__isSafeEnv")return!0;let c=Reflect.get(d,n);return c!==null&&typeof c=="object"&&!Object.isFrozen(c)?I(c):c},set(){throw new Error(w)},deleteProperty(){throw new Error(w)},defineProperty(){throw new Error(w)},setPrototypeOf(){throw new Error(w)}});return $.set(i,o),o}function X(i,o={}){let{loadProcessEnv:d=!0,prefix:n=k,cwd:c,useCache:u=!0,refreshCache:y=!1,envLoader:e}=o;if(y)for(let t in l)delete l[t];let f=typeof window<"u",s=typeof process<"u"&&(!!process.env.VITE||!!process.env[C]),p=f||s||"source"in o,r={},x=!1;if("source"in o)o.source===void 0?(x=!0,r={}):r=o.source;else if(u&&!y&&Object.keys(l).length>0)r=l;else if(typeof process<"u"&&!f)try{let t=o.mode||process.env.NODE_ENV||F,a={};if(e)for(let v of[".env",`.env.${t}`,".env.local",`.env.${t}.local`])a={...a,...e(v,c)};r={...a,...d?process.env:{}}}catch (e2){r={}}u&&!y&&Object.keys(l).length>0?Object.keys(r).length===0?r=l:Object.assign(l,r):u&&Object.keys(r).length>0&&Object.assign(l,r);let h={},E=[];for(let t in i){let a=i[t],v=n&&!t.startsWith(n)?n+t:t,S=a.sourceKey||(r[v]!==void 0?v:r[t]!==void 0?t:v),m=r[S],R={source:r,parsed:h};try{let D=typeof a.required=="function"?a.required(R):a.required;if(m===void 0||m===""&&a.default!==void 0){if(D&&m===void 0)throw new Error("Missing required field");h[t]=a.default}else{let g=a.parse(m,R);if(g!==void 0&&a.metadata){let{min:T,max:V}=a.metadata;if(typeof g=="number"){if(T!==void 0&&g<T)throw new Error(`Below min ${T}`);if(V!==void 0&&g>V)throw new Error(`Above max ${V}`)}}h[t]=g}}catch(D){E.push({key:S,error:D.message,value:m,isSecret:_optionalChain([a, 'access', _2 => _2.metadata, 'optionalAccess', _3 => _3.isSecret])})}}if(E.length>0){if(o.throwOnError){let t=new Error(b(E,!0));throw t.plainMessage=b(E,!1),t}return x||_(E),typeof process<"u"&&process.exit&&!p&&process.exit(1),P(E)}return I(h)}exports.a = F; exports.b = j; exports.c = K; exports.d = C; exports.e = k; exports.f = b; exports.g = _; exports.h = X;
|
package/dist/chunk-JBML47XC.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var F="development",j="serve",K="build",C="VITE_DEV_SERVER",k="VITE_";var O=typeof window<"u"&&typeof window.document<"u";function b(i,o=!0){if(O)return`SafeEnv Validation Failed: ${i.map(s=>`${s.key} (${s.error})`).join(", ")}`;let d={r:"\x1B[31m",g:"\x1B[32m",y:"\x1B[33m",b:"\x1B[1m",res:"\x1B[0m",d:"\x1B[2m",cy:"\x1B[36m"},n=(s,p)=>{let r=String(s),x=()=>r.length+(r.match(/[^\x00-\xff]/g)||[]).length;for(;x()>p;)r=r.slice(0,-1);return r+" ".repeat(p-x())},c=Math.max(80,(typeof process<"u"?process.stdout.columns:80)||80)-10,u=Math.floor(c*.3),y=Math.floor(c*.5),e=o?d:{r:"",g:"",y:"",b:"",res:"",d:"",cy:""},f=`
|
|
2
|
-
${e.r}${e.b}\u274C SafeEnv Validation Failed${e.res}
|
|
3
|
-
`;return f+=` ${e.b}${n("Key",u)} \u2502 ${n("Error",y)} \u2502 Value${e.res}
|
|
4
|
-
`,f+=e.d+"\u2500".repeat(c+5)+e.res+`
|
|
5
|
-
`,i.forEach(s=>{let p=s.value===void 0?"undefined":s.isSecret?"********":`"${s.value}"`,r=s.value===void 0?e.d:s.isSecret?e.y:e.cy;f+=` ${e.y}${n(s.key,u)}${e.res} \u2502 ${e.r}${n(s.error,y)}${e.res} \u2502 ${r}${p}${e.res}
|
|
6
|
-
`}),f+=e.d+"\u2500".repeat(c+5)+e.res+`
|
|
7
|
-
`,f+=` ${e.g}\u{1F4A1} Tip: Check your .env files or schema definitions.${e.res}
|
|
8
|
-
`,f}function _(i){if(O){console.group("%c \u274C SafeEnv Validation Failed ","background: #fee2e2; color: #b91c1c; font-weight: bold; padding: 4px; border-radius: 2px;");let o=i.reduce((d,n)=>(d[n.key]={"Error Message":n.error,"Current Value":n.value===void 0?"undefined":n.isSecret?"********":n.value},d),{});console.table(o),console.log("%c \u{1F4A1} Tip: Check your .env files or schema definitions. ","color: #059669; font-style: italic;"),console.groupEnd()}else console.error(b(i,!0))}var l={},$=new WeakMap;function P(i){let o=b(i,!1);return new Proxy({},{get(d,n){if(n==="__isSafeEnvError")return!0;if(n==="toJSON")return()=>({error:"SafeEnv Validation Failed"});throw new Error(`[safe-env] Cannot access "${String(n)}" because validation failed:
|
|
9
|
-
${o}`)},ownKeys(){return[]},getOwnPropertyDescriptor(){}})}var w="[safe-env] Cannot modify read-only environment variables.";function I(i){if($.has(i))return $.get(i);let o=new Proxy(i,{get(d,n){if(n==="__isSafeEnv")return!0;let c=Reflect.get(d,n);return c!==null&&typeof c=="object"&&!Object.isFrozen(c)?I(c):c},set(){throw new Error(w)},deleteProperty(){throw new Error(w)},defineProperty(){throw new Error(w)},setPrototypeOf(){throw new Error(w)}});return $.set(i,o),o}function X(i,o={}){let{loadProcessEnv:d=!0,prefix:n=k,cwd:c,useCache:u=!0,refreshCache:y=!1,envLoader:e}=o;if(y)for(let t in l)delete l[t];let f=typeof window<"u",s=typeof process<"u"&&(!!process.env.VITE||!!process.env[C]),p=f||s||"source"in o,r={},x=!1;if("source"in o)o.source===void 0?(x=!0,r={}):r=o.source;else if(u&&!y&&Object.keys(l).length>0)r=l;else if(typeof process<"u"&&!f)try{let t=o.mode||process.env.NODE_ENV||F,a={};if(e)for(let v of[".env",`.env.${t}`,".env.local",`.env.${t}.local`])a={...a,...e(v,c)};r={...a,...d?process.env:{}}}catch{r={}}u&&!y&&Object.keys(l).length>0?Object.keys(r).length===0?r=l:Object.assign(l,r):u&&Object.keys(r).length>0&&Object.assign(l,r);let h={},E=[];for(let t in i){let a=i[t],v=n&&!t.startsWith(n)?n+t:t,S=a.sourceKey||(r[v]!==void 0?v:r[t]!==void 0?t:v),m=r[S],R={source:r,parsed:h};try{let D=typeof a.required=="function"?a.required(R):a.required;if(m===void 0||m===""&&a.default!==void 0){if(D&&m===void 0)throw new Error("Missing required field");h[t]=a.default}else{let g=a.parse(m,R);if(g!==void 0&&a.metadata){let{min:T,max:V}=a.metadata;if(typeof g=="number"){if(T!==void 0&&g<T)throw new Error(`Below min ${T}`);if(V!==void 0&&g>V)throw new Error(`Above max ${V}`)}}h[t]=g}}catch(D){E.push({key:S,error:D.message,value:m,isSecret:a.metadata?.isSecret})}}if(E.length>0){if(o.throwOnError){let t=new Error(b(E,!0));throw t.plainMessage=b(E,!1),t}return x||_(E),typeof process<"u"&&process.exit&&!p&&process.exit(1),P(E)}return I(h)}export{F as a,j as b,K as c,C as d,k as e,b as f,_ as g,X as h};
|
package/dist/chunk-TR6KYAQI.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);var _path = require('path'); var _path2 = _interopRequireDefault(_path);function m(r){let n={},i=r.split(/\r?\n/);for(let d of i){let e=d.trim();if(!e||e.startsWith("#"))continue;let o=e.indexOf("=");if(o===-1)continue;let s=e.slice(0,o).trim(),t=e.slice(o+1).trim();if(!t){n[s]="";continue}let c=t[0];if(c==='"'||c==="'"){let l=t.indexOf(c,1);if(l!==-1){n[s]=t.slice(1,l);continue}}let f=t.indexOf("#");f!==-1&&(t=t.slice(0,f).trim()),n[s]=t}return n}function h(r=".env",n){try{let i=_path2.default.resolve(n||process.cwd(),r);if(_fs2.default.existsSync(i))return m(_fs2.default.readFileSync(i,"utf-8"))}catch (e2){}return{}}exports.a = m; exports.b = h;
|