@prosopo/dotenv 2.5.5 → 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 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
@@ -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;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const env = require("./env.cjs");
4
+ exports.getEnv = env.getEnv;
5
+ exports.getEnvFile = env.getEnvFile;
6
+ exports.loadEnv = env.loadEnv;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/dotenv",
3
- "version": "2.5.5",
3
+ "version": "2.6.1",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "types": "./dist/index.d.ts",
27
27
  "dependencies": {
28
- "@prosopo/common": "2.5.5",
29
- "@prosopo/config": "2.5.5",
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
  },