@prosopo/dotenv 3.0.4 → 3.0.6

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @prosopo/dotenv
2
2
 
3
+ ## 3.0.6
4
+ ### Patch Changes
5
+
6
+ - eb71691: configure typecheck before bundle for vue packages
7
+ - eb71691: make typecheck script always recompile
8
+ - Updated dependencies [eb71691]
9
+ - Updated dependencies [eb71691]
10
+ - @prosopo/common@3.1.1
11
+ - @prosopo/config@3.1.2
12
+
13
+ ## 3.0.5
14
+ ### Patch Changes
15
+
16
+ - 3573f0b: fix npm scripts bundle command
17
+ - 3573f0b: build using vite, typecheck using tsc
18
+ - efd8102: Add tests for unwrap error helper
19
+ - 3573f0b: standardise all vite based npm scripts for bundling
20
+ - Updated dependencies [3573f0b]
21
+ - Updated dependencies [3573f0b]
22
+ - Updated dependencies [efd8102]
23
+ - Updated dependencies [f29fc7e]
24
+ - Updated dependencies [3573f0b]
25
+ - Updated dependencies [2d0dd8a]
26
+ - @prosopo/common@3.1.0
27
+ - @prosopo/config@3.1.1
28
+
3
29
  ## 3.0.4
4
30
  ### Patch Changes
5
31
 
package/dist/env.js CHANGED
@@ -1,60 +1,72 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import { LogLevel, getLogger, parseLogLevel } from "@prosopo/common";
4
+ import { getLogger, parseLogLevel, LogLevel } from "@prosopo/common";
5
5
  import dotenv from "dotenv";
6
6
  const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = path.dirname(__filename);
8
- const logger = getLogger(parseLogLevel(process.env.PROSOPO_LOG_LEVEL, LogLevel.enum.info), import.meta.url);
9
- export function getEnv() {
10
- if (process.env.NODE_ENV) {
11
- return process.env.NODE_ENV.replace(/\W/g, "");
12
- }
13
- return "development";
8
+ const logger = getLogger(
9
+ parseLogLevel(process.env.PROSOPO_LOG_LEVEL, LogLevel.enum.info),
10
+ import.meta.url
11
+ );
12
+ function getEnv() {
13
+ if (process.env.NODE_ENV) {
14
+ return process.env.NODE_ENV.replace(/\W/g, "");
15
+ }
16
+ return "development";
14
17
  }
15
- export function loadEnv(rootDir, filename, filePath, nodeEnv, override = false) {
16
- const envPath = getEnvFile(path.resolve(rootDir || "."), filename, filePath, nodeEnv);
17
- const args = { path: envPath, override };
18
- logger.info(() => ({
19
- data: { envPath },
20
- msg: "Loading env",
21
- }));
22
- dotenv.config(args);
23
- return envPath;
18
+ function loadEnv(rootDir, filename, filePath, nodeEnv, override = false) {
19
+ const envPath = getEnvFile(
20
+ path.resolve(rootDir || "."),
21
+ filename,
22
+ filePath,
23
+ nodeEnv
24
+ );
25
+ const args = { path: envPath, override };
26
+ logger.info(() => ({
27
+ data: { envPath },
28
+ msg: "Loading env"
29
+ }));
30
+ dotenv.config(args);
31
+ return envPath;
24
32
  }
25
- export function getEnvFile(rootDir, filename = ".env", filepath = path.join(__dirname, "../.."), nodeEnv) {
26
- const env = nodeEnv || getEnv();
27
- const fileNameFull = `${filename}.${env}`;
28
- let searchPath = path.resolve(rootDir || ".");
29
- logger.info(() => ({
30
- data: { fileName: fileNameFull, searchPath: searchPath },
31
- msg: "Searching",
32
- }));
33
- let levelCount = 0;
34
- while (!fs.existsSync(path.join(searchPath, fileNameFull))) {
35
- if (fs.existsSync(path.join(searchPath, "package.json"))) {
36
- const pkgJson = JSON.parse(fs.readFileSync(path.join(searchPath, "package.json"), "utf8"));
37
- if (pkgJson.name === "@prosopo/captcha-private") {
38
- logger.info(() => ({
39
- data: { fileName: fileNameFull },
40
- msg: "Reached the workspace root package.json, stopping search.",
41
- }));
42
- break;
43
- }
44
- }
45
- searchPath = path.resolve(searchPath, "..");
46
- levelCount += 1;
47
- if (levelCount > 10) {
48
- logger.warn(() => ({
49
- data: { fileName: fileNameFull, levelCount },
50
- msg: "Checked directories above, stopping search.",
51
- }));
52
- break;
53
- }
33
+ function getEnvFile(rootDir, filename = ".env", filepath = path.join(__dirname, "../.."), nodeEnv) {
34
+ const env = nodeEnv || getEnv();
35
+ const fileNameFull = `${filename}.${env}`;
36
+ let searchPath = path.resolve(rootDir || ".");
37
+ logger.info(() => ({
38
+ data: { fileName: fileNameFull, searchPath },
39
+ msg: "Searching"
40
+ }));
41
+ let levelCount = 0;
42
+ while (!fs.existsSync(path.join(searchPath, fileNameFull))) {
43
+ if (fs.existsSync(path.join(searchPath, "package.json"))) {
44
+ const pkgJson = JSON.parse(
45
+ fs.readFileSync(path.join(searchPath, "package.json"), "utf8")
46
+ );
47
+ if (pkgJson.name === "@prosopo/captcha-private") {
48
+ logger.info(() => ({
49
+ data: { fileName: fileNameFull },
50
+ msg: "Reached the workspace root package.json, stopping search."
51
+ }));
52
+ break;
53
+ }
54
+ }
55
+ searchPath = path.resolve(searchPath, "..");
56
+ levelCount += 1;
57
+ if (levelCount > 10) {
58
+ logger.warn(() => ({
59
+ data: { fileName: fileNameFull, levelCount },
60
+ msg: "Checked directories above, stopping search."
61
+ }));
62
+ break;
54
63
  }
55
- const foundPath = path.join(searchPath, fileNameFull);
56
- return fs.existsSync(foundPath)
57
- ? foundPath
58
- : path.join(rootDir || filepath, fileNameFull);
64
+ }
65
+ const foundPath = path.join(searchPath, fileNameFull);
66
+ return fs.existsSync(foundPath) ? foundPath : path.join(rootDir || filepath, fileNameFull);
59
67
  }
60
- //# sourceMappingURL=env.js.map
68
+ export {
69
+ getEnv,
70
+ getEnvFile,
71
+ loadEnv
72
+ };
package/dist/index.js CHANGED
@@ -1,2 +1,6 @@
1
- export * from "./env.js";
2
- //# sourceMappingURL=index.js.map
1
+ import { getEnv, getEnvFile, loadEnv } from "./env.js";
2
+ export {
3
+ getEnv,
4
+ getEnvFile,
5
+ loadEnv
6
+ };
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@prosopo/dotenv",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/cjs/index.cjs"
11
+ }
12
+ },
4
13
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
14
  "license": "Apache-2.0",
6
15
  "private": false,
@@ -9,24 +18,18 @@
9
18
  "npm": "10.8.2"
10
19
  },
11
20
  "scripts": {
12
- "clean": "tsc --build --clean",
13
- "build": "tsc --build --verbose",
14
- "build:cjs": "npx vite --config vite.cjs.config.ts build",
15
- "cli": "node ./dist/js/cli.js",
16
- "test": "echo \"No test specified\""
21
+ "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
22
+ "build": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
23
+ "build:tsc": "tsc --build --verbose",
24
+ "build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
25
+ "typecheck": "tsc --build --declaration --emitDeclarationOnly --force",
26
+ "test": "echo no tests",
27
+ "cli": "node ./dist/js/cli.js"
17
28
  },
18
- "main": "./dist/index.js",
19
29
  "type": "module",
20
- "exports": {
21
- ".": {
22
- "import": "./dist/index.js",
23
- "require": "./dist/cjs/index.cjs"
24
- }
25
- },
26
- "types": "./dist/index.d.ts",
27
30
  "dependencies": {
28
- "@prosopo/common": "3.0.2",
29
- "@prosopo/config": "3.1.0",
31
+ "@prosopo/common": "3.1.1",
32
+ "@prosopo/config": "3.1.2",
30
33
  "@typegoose/auto-increment": "4.13.0",
31
34
  "axios": "1.10.0",
32
35
  "dotenv": "16.4.5",
@@ -15,5 +15,8 @@ import path from "node:path";
15
15
  import { ViteCommonJSConfig } from "@prosopo/config";
16
16
 
17
17
  export default function () {
18
- return ViteCommonJSConfig("util", path.resolve("./tsconfig.cjs.json"));
18
+ return ViteCommonJSConfig(
19
+ path.basename("."),
20
+ path.resolve("./tsconfig.json"),
21
+ );
19
22
  }
@@ -0,0 +1,20 @@
1
+ // Copyright 2021-2025 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import path from "node:path";
16
+ import { ViteEsmConfig } from "@prosopo/config";
17
+
18
+ export default function () {
19
+ return ViteEsmConfig(path.basename("."), path.resolve("./tsconfig.json"));
20
+ }
package/dist/env.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare function getEnv(): string;
2
- export declare function loadEnv(rootDir?: string, filename?: string, filePath?: string, nodeEnv?: string, override?: boolean): string;
3
- export declare function getEnvFile(rootDir?: string, filename?: string, filepath?: string, nodeEnv?: string): string;
4
- //# sourceMappingURL=env.d.ts.map
package/dist/env.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AA2BA,wBAAgB,MAAM,WAKrB;AAED,wBAAgB,OAAO,CACtB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,UAAQ,GACd,MAAM,CAcR;AAUD,wBAAgB,UAAU,CACzB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,SAAS,EACjB,QAAQ,SAAgC,EACxC,OAAO,CAAC,EAAE,MAAM,UA0ChB"}
package/dist/env.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":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CAAC;QACD,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC5C,UAAU,IAAI,CAAC,CAAC;QAChB,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;gBAClB,IAAI,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE;gBAC5C,GAAG,EAAE,6CAA6C;aAClD,CAAC,CAAC,CAAC;YACJ,MAAM;QACP,CAAC;IACF,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACtD,OAAO,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;QAC9B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE,YAAY,CAAC,CAAC;AACjD,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from "./env.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC"}