@vezham/env 0.2.0-poc-env-1 → 0.2.0-poc-env-1.0
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/index.d.ts +0 -1
- package/index.js +1 -3
- package/index.mjs +35 -241
- package/package.json +2 -5
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
2
|
-
`);let o;for(;(o=S.exec(t))!=null;){const c=o[1];let n=o[2]||"";n=n.trim();const s=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),s==='"'&&(n=n.replace(/\\n/g,`
|
|
3
|
-
`),n=n.replace(/\\r/g,"\r")),r[c]=n}return r}function L(e){const r=I(e),t=_.configDotenv({path:r});if(!t.parsed){const s=new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);throw s.code="MISSING_DATA",s}const o=h(e).split(","),c=o.length;let n;for(let s=0;s<c;s++)try{const a=o[s].trim(),l=K(t,a);n=_.decrypt(l.ciphertext,l.key);break}catch(a){if(s+1>=c)throw a}return _.parse(n)}function U(e){console.log(`[dotenv@${g}][INFO] ${e}`)}function C(e){console.log(`[dotenv@${g}][WARN] ${e}`)}function d(e){console.log(`[dotenv@${g}][DEBUG] ${e}`)}function h(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function K(e,r){let t;try{t=new URL(r)}catch(a){if(a.code==="ERR_INVALID_URL"){const l=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw l.code="INVALID_DOTENV_KEY",l}throw a}const o=t.password;if(!o){const a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}const c=t.searchParams.get("environment");if(!c){const a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}const n=`DOTENV_VAULT_${c.toUpperCase()}`,s=e.parsed[n];if(!s){const a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${n} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:s,key:o}}function I(e){let r=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(const t of e.path)N.existsSync(t)&&(r=t.endsWith(".vault")?t:`${t}.vault`);else r=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else r=O.resolve(process.cwd(),".env.vault");return N.existsSync(r)?r:null}function V(e){return e[0]==="~"?O.join(b.homedir(),e.slice(1)):e}function B(e){U("Loading env from encrypted .env.vault");const r=_._parseVault(e);let t=process.env;return e&&e.processEnv!=null&&(t=e.processEnv),_.populate(t,r,e),{parsed:r}}function x(e){const r=O.resolve(process.cwd(),".env");let t="utf8";const o=!!(e&&e.debug);e&&e.encoding?t=e.encoding:o&&d("No encoding is specified. UTF-8 is used by default");let c=[r];if(e&&e.path)if(!Array.isArray(e.path))c=[V(e.path)];else{c=[];for(const l of e.path)c.push(V(l))}let n;const s={};for(const l of c)try{const E=_.parse(N.readFileSync(l,{encoding:t}));_.populate(s,E,e)}catch(E){o&&d(`Failed to load ${l} ${E.message}`),n=E}let a=process.env;return e&&e.processEnv!=null&&(a=e.processEnv),_.populate(a,s,e),n?{parsed:s,error:n}:{parsed:s}}function Y(e){if(h(e).length===0)return _.configDotenv(e);const r=I(e);return r?_._configVault(e):(C(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`),_.configDotenv(e))}function M(e,r){const t=Buffer.from(r.slice(-64),"hex");let o=Buffer.from(e,"base64");const c=o.subarray(0,12),n=o.subarray(-16);o=o.subarray(12,-16);try{const s=R.createDecipheriv("aes-256-gcm",t,c);return s.setAuthTag(n),`${s.update(o)}${s.final()}`}catch(s){const a=s instanceof RangeError,l=s.message==="Invalid key length",E=s.message==="Unsupported state or unable to authenticate data";if(a||l){const p=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw p.code="INVALID_DOTENV_KEY",p}else if(E){const p=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw p.code="DECRYPTION_FAILED",p}else throw s}}function G(e,r,t={}){const o=!!(t&&t.debug),c=!!(t&&t.override);if(typeof r!="object"){const n=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw n.code="OBJECT_REQUIRED",n}for(const n of Object.keys(r))Object.prototype.hasOwnProperty.call(e,n)?(c===!0&&(e[n]=r[n]),o&&d(c===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=r[n]}const _={configDotenv:x,_configVault:B,_parseVault:L,config:Y,decrypt:M,parse:$,populate:G};u.exports.configDotenv=_.configDotenv;u.exports._configVault=_._configVault;u.exports._parseVault=_._parseVault;u.exports.config=_.config;u.exports.decrypt=_.decrypt;u.exports.parse=_.parse;u.exports.populate=_.populate;u.exports=_;var F=u.exports;const f={};process.env.DOTENV_CONFIG_ENCODING!=null&&(f.encoding=process.env.DOTENV_CONFIG_ENCODING);process.env.DOTENV_CONFIG_PATH!=null&&(f.path=process.env.DOTENV_CONFIG_PATH);process.env.DOTENV_CONFIG_DEBUG!=null&&(f.debug=process.env.DOTENV_CONFIG_DEBUG);process.env.DOTENV_CONFIG_OVERRIDE!=null&&(f.override=process.env.DOTENV_CONFIG_OVERRIDE);process.env.DOTENV_CONFIG_DOTENV_KEY!=null&&(f.DOTENV_KEY=process.env.DOTENV_CONFIG_DOTENV_KEY);var k=f;const j=/^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/;var W=function(r){return r.reduce(function(t,o){const c=o.match(j);return c&&(t[c[1]]=c[2]),t},{})};(function(){F.config(Object.assign({},k,W(process.argv)))})();const H={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};console.log("import");console.table({...H});console.log("process");console.table({...process.env});const i={...process.env};console.table(i);const J=i.NODE_ENV!=="production",Q=i.NODE_ENV==="test",q=i.NODE_ENV==="production",X=i.V_IS_PREVIEW==="true",z=i.V_IS_DEBUG==="true",Z=i.V_IS_BETA==="true",ee=i.V_APP_NAME||"v0xapp",D=i.V_BASE_API_URL||"api",te=()=>D==="local"?i.V_MOCK_LOCAL_API_URL:D==="mock"?i.V_MOCK_API_URL:config.domain_type===IAM.DomainType.SANDBOX?i.V_APP_SANDBOX_API_URL:config.domain_type===IAM.DomainType.DC?i.V_APP_DC_API_URL:i.V_APP_API_URL;exports.APP_NAME=ee;exports.BASE_API_URL=D;exports.IS_BETA=Z;exports.__DEBUG__=z;exports.__DEV__=J;exports.__PREVIEW__=X;exports.__PRODUCTION__=q;exports.__TEST__=Q;exports.getApiServerEndPoint=te;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var _=typeof document<"u"?document.currentScript:null;const n={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};try{console.log("V_APP_NAME: ",process.env.V_APP_NAME)}catch{console.log("isVite:",typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.js",document.baseURI).href}<"u"&&"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.js",document.baseURI).href}),console.log("V_APP_NAME:fb")}try{console.log("NODE_ENV: ",process.env.NODE_ENV)}catch{console.log("NODE_ENV:fb")}try{console.table({url:typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.js",document.baseURI).href}),console.table(n)}catch{console.log("import:fb")}try{console.table(process.env)}catch{console.log("process:fb")}let e=process.env||{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.js",document.baseURI).href};const r=e.NODE_ENV!=="production",c=e.NODE_ENV==="test",s=e.NODE_ENV==="production",i=e.V_IS_PREVIEW==="true",l=e.V_IS_DEBUG==="true",a=e.V_IS_BETA==="true",u=e.V_APP_NAME||"v0xapp",t=e.V_BASE_API_URL||"api",E=()=>t==="local"?e.V_MOCK_LOCAL_API_URL:t==="mock"?e.V_MOCK_API_URL:config.domain_type===IAM.DomainType.SANDBOX?e.V_APP_SANDBOX_API_URL:config.domain_type===IAM.DomainType.DC?e.V_APP_DC_API_URL:e.V_APP_API_URL;exports.APP_NAME=u;exports.BASE_API_URL=t;exports.IS_BETA=a;exports.__DEBUG__=l;exports.__DEV__=r;exports.__PREVIEW__=i;exports.__PRODUCTION__=s;exports.__TEST__=c;exports.getApiServerEndPoint=E;
|
package/index.mjs
CHANGED
|
@@ -1,243 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function L(e) {
|
|
28
|
-
const r = {};
|
|
29
|
-
let t = e.toString();
|
|
30
|
-
t = t.replace(/\r\n?/mg, `
|
|
31
|
-
`);
|
|
32
|
-
let o;
|
|
33
|
-
for (; (o = $.exec(t)) != null; ) {
|
|
34
|
-
const c = o[1];
|
|
35
|
-
let n = o[2] || "";
|
|
36
|
-
n = n.trim();
|
|
37
|
-
const s = n[0];
|
|
38
|
-
n = n.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), s === '"' && (n = n.replace(/\\n/g, `
|
|
39
|
-
`), n = n.replace(/\\r/g, "\r")), r[c] = n;
|
|
40
|
-
}
|
|
41
|
-
return r;
|
|
42
|
-
}
|
|
43
|
-
function C(e) {
|
|
44
|
-
const r = I(e), t = i.configDotenv({ path: r });
|
|
45
|
-
if (!t.parsed) {
|
|
46
|
-
const s = new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);
|
|
47
|
-
throw s.code = "MISSING_DATA", s;
|
|
48
|
-
}
|
|
49
|
-
const o = h(e).split(","), c = o.length;
|
|
50
|
-
let n;
|
|
51
|
-
for (let s = 0; s < c; s++)
|
|
52
|
-
try {
|
|
53
|
-
const a = o[s].trim(), _ = x(t, a);
|
|
54
|
-
n = i.decrypt(_.ciphertext, _.key);
|
|
55
|
-
break;
|
|
56
|
-
} catch (a) {
|
|
57
|
-
if (s + 1 >= c)
|
|
58
|
-
throw a;
|
|
59
|
-
}
|
|
60
|
-
return i.parse(n);
|
|
61
|
-
}
|
|
62
|
-
function K(e) {
|
|
63
|
-
console.log(`[dotenv@${O}][INFO] ${e}`);
|
|
64
|
-
}
|
|
65
|
-
function S(e) {
|
|
66
|
-
console.log(`[dotenv@${O}][WARN] ${e}`);
|
|
67
|
-
}
|
|
68
|
-
function v(e) {
|
|
69
|
-
console.log(`[dotenv@${O}][DEBUG] ${e}`);
|
|
70
|
-
}
|
|
71
|
-
function h(e) {
|
|
72
|
-
return e && e.DOTENV_KEY && e.DOTENV_KEY.length > 0 ? e.DOTENV_KEY : process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0 ? process.env.DOTENV_KEY : "";
|
|
73
|
-
}
|
|
74
|
-
function x(e, r) {
|
|
75
|
-
let t;
|
|
76
|
-
try {
|
|
77
|
-
t = new URL(r);
|
|
78
|
-
} catch (a) {
|
|
79
|
-
if (a.code === "ERR_INVALID_URL") {
|
|
80
|
-
const _ = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
81
|
-
throw _.code = "INVALID_DOTENV_KEY", _;
|
|
82
|
-
}
|
|
83
|
-
throw a;
|
|
84
|
-
}
|
|
85
|
-
const o = t.password;
|
|
86
|
-
if (!o) {
|
|
87
|
-
const a = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
88
|
-
throw a.code = "INVALID_DOTENV_KEY", a;
|
|
89
|
-
}
|
|
90
|
-
const c = t.searchParams.get("environment");
|
|
91
|
-
if (!c) {
|
|
92
|
-
const a = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
93
|
-
throw a.code = "INVALID_DOTENV_KEY", a;
|
|
94
|
-
}
|
|
95
|
-
const n = `DOTENV_VAULT_${c.toUpperCase()}`, s = e.parsed[n];
|
|
96
|
-
if (!s) {
|
|
97
|
-
const a = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${n} in your .env.vault file.`);
|
|
98
|
-
throw a.code = "NOT_FOUND_DOTENV_ENVIRONMENT", a;
|
|
99
|
-
}
|
|
100
|
-
return { ciphertext: s, key: o };
|
|
101
|
-
}
|
|
102
|
-
function I(e) {
|
|
103
|
-
let r = null;
|
|
104
|
-
if (e && e.path && e.path.length > 0)
|
|
105
|
-
if (Array.isArray(e.path))
|
|
106
|
-
for (const t of e.path)
|
|
107
|
-
N.existsSync(t) && (r = t.endsWith(".vault") ? t : `${t}.vault`);
|
|
108
|
-
else
|
|
109
|
-
r = e.path.endsWith(".vault") ? e.path : `${e.path}.vault`;
|
|
110
|
-
else
|
|
111
|
-
r = D.resolve(process.cwd(), ".env.vault");
|
|
112
|
-
return N.existsSync(r) ? r : null;
|
|
113
|
-
}
|
|
114
|
-
function g(e) {
|
|
115
|
-
return e[0] === "~" ? D.join(b.homedir(), e.slice(1)) : e;
|
|
116
|
-
}
|
|
117
|
-
function U(e) {
|
|
118
|
-
K("Loading env from encrypted .env.vault");
|
|
119
|
-
const r = i._parseVault(e);
|
|
120
|
-
let t = process.env;
|
|
121
|
-
return e && e.processEnv != null && (t = e.processEnv), i.populate(t, r, e), { parsed: r };
|
|
122
|
-
}
|
|
123
|
-
function Y(e) {
|
|
124
|
-
const r = D.resolve(process.cwd(), ".env");
|
|
125
|
-
let t = "utf8";
|
|
126
|
-
const o = !!(e && e.debug);
|
|
127
|
-
e && e.encoding ? t = e.encoding : o && v("No encoding is specified. UTF-8 is used by default");
|
|
128
|
-
let c = [r];
|
|
129
|
-
if (e && e.path)
|
|
130
|
-
if (!Array.isArray(e.path))
|
|
131
|
-
c = [g(e.path)];
|
|
132
|
-
else {
|
|
133
|
-
c = [];
|
|
134
|
-
for (const _ of e.path)
|
|
135
|
-
c.push(g(_));
|
|
136
|
-
}
|
|
137
|
-
let n;
|
|
138
|
-
const s = {};
|
|
139
|
-
for (const _ of c)
|
|
140
|
-
try {
|
|
141
|
-
const f = i.parse(N.readFileSync(_, { encoding: t }));
|
|
142
|
-
i.populate(s, f, e);
|
|
143
|
-
} catch (f) {
|
|
144
|
-
o && v(`Failed to load ${_} ${f.message}`), n = f;
|
|
145
|
-
}
|
|
146
|
-
let a = process.env;
|
|
147
|
-
return e && e.processEnv != null && (a = e.processEnv), i.populate(a, s, e), n ? { parsed: s, error: n } : { parsed: s };
|
|
148
|
-
}
|
|
149
|
-
function B(e) {
|
|
150
|
-
if (h(e).length === 0)
|
|
151
|
-
return i.configDotenv(e);
|
|
152
|
-
const r = I(e);
|
|
153
|
-
return r ? i._configVault(e) : (S(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`), i.configDotenv(e));
|
|
154
|
-
}
|
|
155
|
-
function F(e, r) {
|
|
156
|
-
const t = Buffer.from(r.slice(-64), "hex");
|
|
157
|
-
let o = Buffer.from(e, "base64");
|
|
158
|
-
const c = o.subarray(0, 12), n = o.subarray(-16);
|
|
159
|
-
o = o.subarray(12, -16);
|
|
160
|
-
try {
|
|
161
|
-
const s = w.createDecipheriv("aes-256-gcm", t, c);
|
|
162
|
-
return s.setAuthTag(n), `${s.update(o)}${s.final()}`;
|
|
163
|
-
} catch (s) {
|
|
164
|
-
const a = s instanceof RangeError, _ = s.message === "Invalid key length", f = s.message === "Unsupported state or unable to authenticate data";
|
|
165
|
-
if (a || _) {
|
|
166
|
-
const p = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
167
|
-
throw p.code = "INVALID_DOTENV_KEY", p;
|
|
168
|
-
} else if (f) {
|
|
169
|
-
const p = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
170
|
-
throw p.code = "DECRYPTION_FAILED", p;
|
|
171
|
-
} else
|
|
172
|
-
throw s;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function G(e, r, t = {}) {
|
|
176
|
-
const o = !!(t && t.debug), c = !!(t && t.override);
|
|
177
|
-
if (typeof r != "object") {
|
|
178
|
-
const n = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
179
|
-
throw n.code = "OBJECT_REQUIRED", n;
|
|
180
|
-
}
|
|
181
|
-
for (const n of Object.keys(r))
|
|
182
|
-
Object.prototype.hasOwnProperty.call(e, n) ? (c === !0 && (e[n] = r[n]), o && v(c === !0 ? `"${n}" is already defined and WAS overwritten` : `"${n}" is already defined and was NOT overwritten`)) : e[n] = r[n];
|
|
183
|
-
}
|
|
184
|
-
const i = {
|
|
185
|
-
configDotenv: Y,
|
|
186
|
-
_configVault: U,
|
|
187
|
-
_parseVault: C,
|
|
188
|
-
config: B,
|
|
189
|
-
decrypt: F,
|
|
190
|
-
parse: L,
|
|
191
|
-
populate: G
|
|
192
|
-
};
|
|
193
|
-
u.exports.configDotenv = i.configDotenv;
|
|
194
|
-
u.exports._configVault = i._configVault;
|
|
195
|
-
u.exports._parseVault = i._parseVault;
|
|
196
|
-
u.exports.config = i.config;
|
|
197
|
-
u.exports.decrypt = i.decrypt;
|
|
198
|
-
u.exports.parse = i.parse;
|
|
199
|
-
u.exports.populate = i.populate;
|
|
200
|
-
u.exports = i;
|
|
201
|
-
var M = u.exports;
|
|
202
|
-
const E = {};
|
|
203
|
-
process.env.DOTENV_CONFIG_ENCODING != null && (E.encoding = process.env.DOTENV_CONFIG_ENCODING);
|
|
204
|
-
process.env.DOTENV_CONFIG_PATH != null && (E.path = process.env.DOTENV_CONFIG_PATH);
|
|
205
|
-
process.env.DOTENV_CONFIG_DEBUG != null && (E.debug = process.env.DOTENV_CONFIG_DEBUG);
|
|
206
|
-
process.env.DOTENV_CONFIG_OVERRIDE != null && (E.override = process.env.DOTENV_CONFIG_OVERRIDE);
|
|
207
|
-
process.env.DOTENV_CONFIG_DOTENV_KEY != null && (E.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY);
|
|
208
|
-
var k = E;
|
|
209
|
-
const j = /^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/;
|
|
210
|
-
var W = function(r) {
|
|
211
|
-
return r.reduce(function(t, o) {
|
|
212
|
-
const c = o.match(j);
|
|
213
|
-
return c && (t[c[1]] = c[2]), t;
|
|
214
|
-
}, {});
|
|
215
|
-
};
|
|
216
|
-
(function() {
|
|
217
|
-
M.config(
|
|
218
|
-
Object.assign(
|
|
219
|
-
{},
|
|
220
|
-
k,
|
|
221
|
-
W(process.argv)
|
|
222
|
-
)
|
|
223
|
-
);
|
|
224
|
-
})();
|
|
225
|
-
const H = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
226
|
-
console.log("import");
|
|
227
|
-
console.table({ ...H });
|
|
228
|
-
console.log("process");
|
|
229
|
-
console.table({ ...process.env });
|
|
230
|
-
const l = { ...process.env };
|
|
231
|
-
console.table(l);
|
|
232
|
-
const J = l.NODE_ENV !== "production", Q = l.NODE_ENV === "test", q = l.NODE_ENV === "production", X = l.V_IS_PREVIEW === "true", z = l.V_IS_DEBUG === "true", Z = l.V_IS_BETA === "true", ee = l.V_APP_NAME || "v0xapp", V = l.V_BASE_API_URL || "api", te = () => V === "local" ? l.V_MOCK_LOCAL_API_URL : V === "mock" ? l.V_MOCK_API_URL : config.domain_type === IAM.DomainType.SANDBOX ? l.V_APP_SANDBOX_API_URL : config.domain_type === IAM.DomainType.DC ? l.V_APP_DC_API_URL : l.V_APP_API_URL;
|
|
1
|
+
const t = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
2
|
+
try {
|
|
3
|
+
console.log("V_APP_NAME: ", process.env.V_APP_NAME);
|
|
4
|
+
} catch {
|
|
5
|
+
console.log(
|
|
6
|
+
"isVite:",
|
|
7
|
+
typeof import.meta < "u" && "env" in import.meta
|
|
8
|
+
), console.log("V_APP_NAME:fb");
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
console.log("NODE_ENV: ", process.env.NODE_ENV);
|
|
12
|
+
} catch {
|
|
13
|
+
console.log("NODE_ENV:fb");
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
console.table(import.meta), console.table(t);
|
|
17
|
+
} catch {
|
|
18
|
+
console.log("import:fb");
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
console.table(process.env);
|
|
22
|
+
} catch {
|
|
23
|
+
console.log("process:fb");
|
|
24
|
+
}
|
|
25
|
+
let _ = process.env || import.meta || {};
|
|
26
|
+
const r = _.NODE_ENV !== "production", n = _.NODE_ENV === "test", c = _.NODE_ENV === "production", s = _.V_IS_PREVIEW === "true", E = _.V_IS_DEBUG === "true", A = _.V_IS_BETA === "true", l = _.V_APP_NAME || "v0xapp", e = _.V_BASE_API_URL || "api", P = () => e === "local" ? _.V_MOCK_LOCAL_API_URL : e === "mock" ? _.V_MOCK_API_URL : config.domain_type === IAM.DomainType.SANDBOX ? _.V_APP_SANDBOX_API_URL : config.domain_type === IAM.DomainType.DC ? _.V_APP_DC_API_URL : _.V_APP_API_URL;
|
|
233
27
|
export {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
28
|
+
l as APP_NAME,
|
|
29
|
+
e as BASE_API_URL,
|
|
30
|
+
A as IS_BETA,
|
|
31
|
+
E as __DEBUG__,
|
|
32
|
+
r as __DEV__,
|
|
33
|
+
s as __PREVIEW__,
|
|
34
|
+
c as __PRODUCTION__,
|
|
35
|
+
n as __TEST__,
|
|
36
|
+
P as getApiServerEndPoint
|
|
243
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vezham/env",
|
|
3
|
-
"version": "0.2.0-poc-env-1",
|
|
3
|
+
"version": "0.2.0-poc-env-1.0",
|
|
4
4
|
"description": "A package for managing env",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,8 +15,5 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"main": "./index.js",
|
|
18
|
-
"types": "./index.d.ts"
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"dotenv": "^16.4.7"
|
|
21
|
-
}
|
|
18
|
+
"types": "./index.d.ts"
|
|
22
19
|
}
|