@stryke/env 0.18.0 → 0.18.2
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/load-env.cjs +1 -1
- package/dist/load-env.mjs +1 -1
- package/package.json +4 -4
package/dist/load-env.cjs
CHANGED
|
@@ -10,8 +10,8 @@ exports.loadEnvFile = loadEnvFile;
|
|
|
10
10
|
exports.loadServerEnv = loadServerEnv;
|
|
11
11
|
var _dotenvx = require("@dotenvx/dotenvx");
|
|
12
12
|
var _toArray = require("@stryke/convert/to-array");
|
|
13
|
+
var _exists = require("@stryke/fs/exists");
|
|
13
14
|
var _readFile = require("@stryke/fs/read-file");
|
|
14
|
-
var _exists = require("@stryke/path/exists");
|
|
15
15
|
var _joinPaths = require("@stryke/path/join-paths");
|
|
16
16
|
var _defu = _interopRequireDefault(require("defu"));
|
|
17
17
|
var _types = require("./types.cjs");
|
package/dist/load-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parse as E}from"@dotenvx/dotenvx";import{toArray as v}from"@stryke/convert/to-array";import{
|
|
1
|
+
import{parse as E}from"@dotenvx/dotenvx";import{toArray as v}from"@stryke/convert/to-array";import{existsSync as d}from"@stryke/fs/exists";import{readFile as m}from"@stryke/fs/read-file";import{joinPaths as p}from"@stryke/path/join-paths";import f from"defu";import{ENV_PREFIXES as g}from"./types";export function getEnvFilesForMode(r,s="production"){return[".env",".env.local",`.env.${s}`,`.env.${s}.local`,`.env.local.${s}`].map(i=>p(r,i))}export async function loadEnvFile(r,s=[]){const i=Array.isArray(s)?s:[s];return(await Promise.all((s.length>0?i.map(e=>p(e,r)):[r]).map(async e=>{if(d(e))return m(e)}))).reduce((e,a)=>{if(!a)return e;const u=E(a,{processEnv:{...process.env},privateKey:process.env.DOTENV_PRIVATE_KEY||process.env.STORM_PRIVATE_KEY});return f(u,e)},{})}export async function loadEnv(r,s,i){if(s==="local")throw new Error('"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.');const e=v(i).reduce((n,t)=>(t&&(n.includes(t.endsWith("_")?t:`${t}_`)||n.push(t.endsWith("_")?t:`${t}_`),n.includes(`${t.endsWith("_")?t:`${t}_`}PUBLIC_`)||n.push(`${t.endsWith("_")?t:`${t}_`}PUBLIC_`)),n),[]),a=Array.isArray(r)?r:[r],u={},l=a.reduce((n,t)=>(n.push(...getEnvFilesForMode(t,s).filter(c=>!n.includes(c))),n),[]);let o=(await Promise.all(l.map(async n=>loadEnvFile(n)))).reduce((n,t)=>f(t,n),{});if(o.NODE_ENV&&process.env.VITE_USER_NODE_ENV===void 0&&(process.env.VITE_USER_NODE_ENV=JSON.stringify(o.NODE_ENV)),o.BROWSER&&process.env.BROWSER===void 0&&(process.env.BROWSER=JSON.stringify(o.BROWSER)),o.BROWSER_ARGS&&process.env.BROWSER_ARGS===void 0&&(process.env.BROWSER_ARGS=JSON.stringify(o.BROWSER_ARGS)),o=f({...process.env},o),e.length===0)return o;for(const[n,t]of Object.entries(o))e.some(c=>n.startsWith(c))&&(u[n]=String(t));for(const n in process.env)e.some(t=>n.startsWith(t))&&(u[n]=process.env[n]);return u}export async function loadClientEnv(r,s,i=g){return loadEnv(r,s,i)}export async function loadServerEnv(r,s){return loadEnv(r,s)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/env",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing utility functions to handle environment specific processes",
|
|
6
6
|
"repository": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@dotenvx/dotenvx": "1.35.0",
|
|
14
14
|
"@stryke/convert": "^0.3.1",
|
|
15
|
-
"@stryke/fs": "^0.
|
|
16
|
-
"@stryke/path": "^0.
|
|
15
|
+
"@stryke/fs": "^0.27.0",
|
|
16
|
+
"@stryke/path": "^0.13.1",
|
|
17
17
|
"@stryke/string-format": "^0.10.0",
|
|
18
18
|
"defu": "^6.1.4"
|
|
19
19
|
},
|
|
@@ -175,5 +175,5 @@
|
|
|
175
175
|
"main": "./dist/index.cjs",
|
|
176
176
|
"module": "./dist/index.mjs",
|
|
177
177
|
"types": "./dist/index.d.ts",
|
|
178
|
-
"gitHead": "
|
|
178
|
+
"gitHead": "7ec1f888f4eb3038ac5316409189322fda2e5aa6"
|
|
179
179
|
}
|