@prosopo/dotenv 2.5.3 → 2.6.1
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/CHANGELOG.md +20 -0
- package/dist/cjs/env.cjs +64 -0
- package/dist/cjs/index.cjs +6 -0
- package/package.json +6 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @prosopo/dotenv
|
|
2
|
+
|
|
3
|
+
## 2.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [04cc7ee]
|
|
8
|
+
- @prosopo/common@2.6.1
|
|
9
|
+
|
|
10
|
+
## 2.6.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- a0bfc8a: bump all pkg versions since independent versioning applied
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [a0bfc8a]
|
|
19
|
+
- @prosopo/config@2.6.0
|
|
20
|
+
- @prosopo/common@2.6.0
|
package/dist/cjs/env.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const node_url = require("node:url");
|
|
6
|
+
const common = require("@prosopo/common");
|
|
7
|
+
const dotenv = require("dotenv");
|
|
8
|
+
const __filename$1 = node_url.fileURLToPath(module);
|
|
9
|
+
const __dirname$1 = path.dirname(__filename$1);
|
|
10
|
+
const logger = common.getLogger(
|
|
11
|
+
process.env.PROSOPO_LOG_LEVEL || common.LogLevel.enum.info,
|
|
12
|
+
"env"
|
|
13
|
+
);
|
|
14
|
+
function getEnv() {
|
|
15
|
+
if (process.env.NODE_ENV) {
|
|
16
|
+
return process.env.NODE_ENV.replace(/\W/g, "");
|
|
17
|
+
}
|
|
18
|
+
return "development";
|
|
19
|
+
}
|
|
20
|
+
function loadEnv(rootDir, filename, filePath, nodeEnv, override = false) {
|
|
21
|
+
const envPath = getEnvFile(
|
|
22
|
+
path.resolve(rootDir || "."),
|
|
23
|
+
filename,
|
|
24
|
+
filePath,
|
|
25
|
+
nodeEnv
|
|
26
|
+
);
|
|
27
|
+
const args = { path: envPath, override };
|
|
28
|
+
logger.info(`Loading env from ${envPath}`);
|
|
29
|
+
dotenv.config(args);
|
|
30
|
+
return envPath;
|
|
31
|
+
}
|
|
32
|
+
function getEnvFile(rootDir, filename = ".env", filepath = path.join(__dirname$1, "../.."), nodeEnv) {
|
|
33
|
+
const env = nodeEnv || getEnv();
|
|
34
|
+
const fileNameFull = `${filename}.${env}`;
|
|
35
|
+
let searchPath = path.resolve(rootDir || ".");
|
|
36
|
+
logger.info(`Searching for ${fileNameFull} in ${searchPath}`);
|
|
37
|
+
let levelCount = 0;
|
|
38
|
+
while (!fs.existsSync(path.join(searchPath, fileNameFull))) {
|
|
39
|
+
if (fs.existsSync(path.join(searchPath, "package.json"))) {
|
|
40
|
+
const pkgJson = JSON.parse(
|
|
41
|
+
fs.readFileSync(path.join(searchPath, "package.json"), "utf8")
|
|
42
|
+
);
|
|
43
|
+
if (pkgJson.name === "@prosopo/captcha-private") {
|
|
44
|
+
logger.info(
|
|
45
|
+
`Reached the workspace root package.json, stopping search for ${fileNameFull}.`
|
|
46
|
+
);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
searchPath = path.resolve(searchPath, "..");
|
|
51
|
+
levelCount += 1;
|
|
52
|
+
if (levelCount > 10) {
|
|
53
|
+
logger.warn(
|
|
54
|
+
`Checked ${levelCount} directories above, stopping search for ${fileNameFull}.`
|
|
55
|
+
);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const foundPath = path.join(searchPath, fileNameFull);
|
|
60
|
+
return fs.existsSync(foundPath) ? foundPath : path.join(rootDir || filepath, fileNameFull);
|
|
61
|
+
}
|
|
62
|
+
exports.getEnv = getEnv;
|
|
63
|
+
exports.getEnvFile = getEnvFile;
|
|
64
|
+
exports.loadEnv = loadEnv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/dotenv",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -25,21 +25,21 @@
|
|
|
25
25
|
},
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@prosopo/common": "2.
|
|
29
|
-
"@prosopo/config": "2.
|
|
28
|
+
"@prosopo/common": "2.6.1",
|
|
29
|
+
"@prosopo/config": "2.6.0",
|
|
30
30
|
"dotenv": "16.4.5",
|
|
31
31
|
"express": "4.21.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@vitest/coverage-v8": "
|
|
34
|
+
"@vitest/coverage-v8": "3.0.9",
|
|
35
35
|
"concurrently": "9.0.1",
|
|
36
36
|
"del-cli": "6.0.0",
|
|
37
37
|
"npm-run-all": "2.1.0",
|
|
38
38
|
"tslib": "2.7.0",
|
|
39
39
|
"tsx": "4.19.1",
|
|
40
40
|
"typescript": "5.6.2",
|
|
41
|
-
"vite": "
|
|
42
|
-
"vitest": "
|
|
41
|
+
"vite": "6.2.3",
|
|
42
|
+
"vitest": "3.0.9"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|