kuwan-expresspack-core 0.1.17 → 0.1.18

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.
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ import { config } from '@dotenvx/dotenvx';
3
+ import { colorize } from 'consola/utils';
4
+ import w from 'consola';
5
+
6
+ var m=colorize;function N(r){switch(typeof r){case "number":case "bigint":return colorize("cyan",r.toString());case "boolean":return colorize(r?"green":"red",String(r));case "symbol":return colorize("magenta",r.toString());case "string":return isNaN(Number(r))?colorize("whiteBright",`${r}`):colorize("yellow",`'${r}'`);case "undefined":return colorize("gray","undefined")}return r===null?colorize("dim","null"):String(r)}var P=w.create({level:Number.isNaN(Number(process.env.EXPRESSPACK_LOG_LEVEL))?3:Number(process.env.EXPRESSPACK_LOG_LEVEL)});function b(){let r=Number(process.env.EXPRESSPACK_LOG_LEVEL);P.level=Number.isNaN(r)?3:r;}var s=P;var d,c=null,v=null,y={},E=[];function I(r,n){let t=r.safeParse(n);if(t.success)return t.data;console.error("\u274C Invalid environment variables:"),console.error(z.prettifyError(t.error));}function R(r,n,t={fatal:false,immediate_log_error:true,log_error_after_graceful_start:true}){if(b(),y=t,t.fatal)try{let o=r.parse(n);return {...d,...o}}catch(o){throw o instanceof z.ZodError?(c=z.prettifyError(o),v=o,s.error("\u274C Invalid environment variables:"),s.error("\u274C",c),new Error("Invalid environment variables. The environment variable did not pass the schema validation. Check if you have set all required environment variables correctly.")):o}let i=r.safeParse(n);if(!i.success){let o=r.partial().safeParse(n);if(!o.success)return c=z.prettifyError(i.error),v=i.error,t.immediate_log_error&&(s.error("\u274C Invalid environment variables:"),s.error("\u274C",c)),d||{};c=z.prettifyError(i.error),v=i.error,t.immediate_log_error&&(s.error("\u274C Invalid environment variables:"),s.error("\u274C",c));let f=r.keyof();E=f.options;for(let p of f.options)p in o.data||(o.data[p]=void 0);return {...d,...o.data}}let a=r.keyof();E=a.options;for(let o of a.options)o in i.data||(i.data[o]=void 0);return {...d,...i.data}}function T(){return v}function S(){return c}function L(r){if(!r||Object.keys(r).length===0){s.warn("No environment variables to print. Make sure the env is complete and valid.");return}let n=e=>e.startsWith("* ")?m("dim",e):e,t=e=>E.includes(e)?e:`* ${e}`,i=e=>e.startsWith("! ")?m("dim",m("yellow",`${e}`)):e,a=e=>E.includes(e)&&r[e]===void 0?`! ${e}`:e,o=Object.entries(r).sort(([e],[l])=>e.localeCompare(l)).map(([e,l])=>[t(e),l]).map(([e,l])=>[a(e),l]),f=Math.max(...o.map(([e])=>e.length))+2,p=o.map(([e,l])=>`${e.padEnd(f," ").replace(e,n(e)).replace(e,i(e))} ${N(l)}`),_=`KEY${" ".repeat(f-3)} VALUE`,h=" ".repeat(_.length);return [h,_,h,...p].join(`
7
+ `)}function $(){if(y){let{log_error_after_graceful_start:r}=y;if(r){let n=S();n&&s.error("Invalid Environment Variable Value",`
8
+ -----
9
+ ${n}
10
+ -----`);}}}function k(r,n){s.log("[Environment Variables] on `env.ts`");let t=Object.fromEntries(Object.entries({...r}).map(([i,a])=>typeof a=="string"&&a.length>36?[i,`${a.slice(0,36)}...`]:n?n(i,a):[i,a]));s.log(`${L(t)}
11
+ `);}function C(r){d={};let n=config(r);return b(),d=n.parsed?n.parsed:void 0,n}function K(r){return new Proxy(r,{get(n,t){return t in n?n[t]:process.env[t]}})}function j(r,n,t){let i=R(r,n,t);return K(i)}var H={create:j,parseEnv:I,prettifyEnv:L,getEnvErrorRaw:T,getEnvErrorString:S,logEnvErrors:$,config:C};
12
+
13
+ export { s as a, R as b, T as c, S as d, L as e, $ as f, k as g, C as h, H as i };
@@ -1,3 +1,3 @@
1
- import { g } from './chunk-CZGPAGDK.mjs';
1
+ import { h } from './chunk-XWAHBJNF.mjs';
2
2
 
3
- g();
3
+ h();
package/dist/env.d.ts CHANGED
@@ -55,6 +55,13 @@ declare function prettifyEnv(env: Record<string, any>): string | undefined;
55
55
  * Errors are already logged after by graceful start.
56
56
  */
57
57
  declare function logEnvErrors(): void;
58
+ /**
59
+ * This will print the passed env vars regardless of the NODE_ENV,
60
+ * it is on your discretion on when to call this function.
61
+ *
62
+ * @param envVars The environment variables to log
63
+ */
64
+ declare function debugEnvVars(envVars: Record<string, any>, redactFunction?: (key: string, value: any) => [string, any]): void;
58
65
  declare function config(options?: DotenvConfigOptions | undefined): DotenvConfigOutput;
59
66
  declare function createProxy<T extends z.ZodObject<any>>(schema: T, data: unknown, options?: Partial<EnvOptions>): z.output<T>;
60
67
  declare const _default: {
@@ -67,4 +74,4 @@ declare const _default: {
67
74
  config: typeof config;
68
75
  };
69
76
 
70
- export { type EnvOptions, config, create, _default as default, getEnvErrorRaw, getEnvErrorString, logEnvErrors, prettifyEnv };
77
+ export { type EnvOptions, config, create, debugEnvVars, _default as default, getEnvErrorRaw, getEnvErrorString, logEnvErrors, prettifyEnv };
package/dist/env.mjs CHANGED
@@ -1 +1 @@
1
- export { g as config, b as create, h as default, c as getEnvErrorRaw, d as getEnvErrorString, f as logEnvErrors, e as prettifyEnv } from './chunk-CZGPAGDK.mjs';
1
+ export { h as config, b as create, g as debugEnvVars, i as default, c as getEnvErrorRaw, d as getEnvErrorString, f as logEnvErrors, e as prettifyEnv } from './chunk-XWAHBJNF.mjs';
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { e } from './chunk-OXUMMLIO.mjs';
2
2
  import { a as a$1 } from './chunk-JKH5TYED.mjs';
3
3
  import { a as a$2 } from './chunk-VSPZT4K6.mjs';
4
- import { a, f } from './chunk-CZGPAGDK.mjs';
4
+ import { a, f } from './chunk-XWAHBJNF.mjs';
5
5
  import { Router } from 'express';
6
6
  import M, { relative, join } from 'path';
7
7
  import { existsSync } from 'fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuwan-expresspack-core",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -1,12 +0,0 @@
1
- import { z as z$1 } from 'zod';
2
- import { config } from '@dotenvx/dotenvx';
3
- import { colorize } from 'consola/utils';
4
- import L from 'consola';
5
-
6
- var m=colorize;function N(r){switch(typeof r){case "number":case "bigint":return colorize("cyan",r.toString());case "boolean":return colorize(r?"green":"red",String(r));case "symbol":return colorize("magenta",r.toString());case "string":return isNaN(Number(r))?colorize("whiteBright",`${r}`):colorize("yellow",`'${r}'`);case "undefined":return colorize("gray","undefined")}return r===null?colorize("dim","null"):String(r)}var P=L.create({level:Number.isNaN(Number(process.env.EXPRESSPACK_LOG_LEVEL))?3:Number(process.env.EXPRESSPACK_LOG_LEVEL)});function b(){let r=Number(process.env.EXPRESSPACK_LOG_LEVEL);P.level=Number.isNaN(r)?3:r;}var s=P;var c,l=null,v=null,y={},E=[];function z(r,n){let o=r.safeParse(n);if(o.success)return o.data;console.error("\u274C Invalid environment variables:"),console.error(z$1.prettifyError(o.error));}function I(r,n,o={fatal:false,immediate_log_error:true,log_error_after_graceful_start:true}){if(b(),y=o,o.fatal)try{let t=r.parse(n);return {...c,...t}}catch(t){throw t instanceof z$1.ZodError?(l=z$1.prettifyError(t),v=t,s.error("\u274C Invalid environment variables:"),s.error("\u274C",l),new Error("Invalid environment variables. The environment variable did not pass the schema validation. Check if you have set all required environment variables correctly.")):t}let i=r.safeParse(n);if(!i.success){let t=r.partial().safeParse(n);if(!t.success)return l=z$1.prettifyError(i.error),v=i.error,o.immediate_log_error&&(s.error("\u274C Invalid environment variables:"),s.error("\u274C",l)),c||{};l=z$1.prettifyError(i.error),v=i.error,o.immediate_log_error&&(s.error("\u274C Invalid environment variables:"),s.error("\u274C",l));let d=r.keyof();E=d.options;for(let p of d.options)p in t.data||(t.data[p]=void 0);return {...c,...t.data}}let g=r.keyof();E=g.options;for(let t of g.options)t in i.data||(i.data[t]=void 0);return {...c,...i.data}}function R(){return v}function S(){return l}function T(r){if(!r||Object.keys(r).length===0){s.warn("No environment variables to print. Make sure the env is complete and valid.");return}let n=e=>e.startsWith("* ")?m("dim",e):e,o=e=>E.includes(e)?e:`* ${e}`,i=e=>e.startsWith("! ")?m("dim",m("yellow",`${e}`)):e,g=e=>E.includes(e)&&r[e]===void 0?`! ${e}`:e,t=Object.entries(r).sort(([e],[u])=>e.localeCompare(u)).map(([e,u])=>[o(e),u]).map(([e,u])=>[g(e),u]),d=Math.max(...t.map(([e])=>e.length))+2,p=t.map(([e,u])=>`${e.padEnd(d," ").replace(e,n(e)).replace(e,i(e))} ${N(u)}`),_=`KEY${" ".repeat(d-3)} VALUE`,h=" ".repeat(_.length);return [h,_,h,...p].join(`
7
- `)}function C(){if(y){let{log_error_after_graceful_start:r}=y;if(r){let n=S();n&&s.error("Invalid Environment Variable Value",`
8
- -----
9
- ${n}
10
- -----`);}}}function K(r){c={};let n=config(r);return b(),c=n.parsed?n.parsed:void 0,n}function $(r){return new Proxy(r,{get(n,o){return o in n?n[o]:process.env[o]}})}function j(r,n,o){let i=I(r,n,o);return $(i)}var Y={create:j,parseEnv:z,prettifyEnv:T,getEnvErrorRaw:R,getEnvErrorString:S,logEnvErrors:C,config:K};
11
-
12
- export { s as a, I as b, R as c, S as d, T as e, C as f, K as g, Y as h };