@hobenakicoffee/libraries 1.21.0 → 1.21.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hobenakicoffee/libraries",
3
- "version": "1.21.0",
3
+ "version": "1.21.1",
4
4
  "type": "module",
5
5
  "types": "src/index.ts",
6
6
  "exports": {
@@ -1,38 +1,31 @@
1
- import Bun from "bun";
1
+ import { existsSync, readFileSync } from "node:fs";
2
2
 
3
- export async function checkEnvEncryption(
3
+ export function checkEnvEncryption(
4
4
  envFiles: string[] = [".env", ".env.production"]
5
5
  ) {
6
6
  const ALLOWED = new Set([
7
7
  "DOTENV_PUBLIC_KEY",
8
8
  "DOTENV_PUBLIC_KEY_PRODUCTION",
9
9
  ]);
10
-
11
10
  let hasError = false;
12
11
 
13
12
  for (const file of envFiles) {
14
- const f = Bun.file(file);
15
-
16
- if (!(await f.exists())) {
13
+ if (!existsSync(file)) {
17
14
  console.warn(`⚠️ Skipping missing file: ${file}`);
18
15
  continue;
19
16
  }
20
17
 
21
- const text = await f.text();
18
+ const text = readFileSync(file, "utf-8");
22
19
  const lines = text.split("\n");
23
20
 
24
21
  for (const line of lines) {
25
22
  const trimmed = line.trim();
26
23
  if (!trimmed || trimmed.startsWith("#")) continue;
27
-
28
24
  const [key, ...rest] = trimmed.split("=");
29
25
  if (!key || rest.length === 0) continue;
30
-
31
26
  let value = rest.join("=").trim();
32
27
  value = value.replace(/^['"]|['"]$/g, "");
33
-
34
28
  if (ALLOWED.has(key)) continue;
35
-
36
29
  if (!value.startsWith("encrypted:")) {
37
30
  console.error(`❌ ${file} -> ${key} is not encrypted`);
38
31
  hasError = true;
@@ -44,11 +37,15 @@ export async function checkEnvEncryption(
44
37
  console.error("\n🚨 Env encryption validation failed");
45
38
  process.exit(1);
46
39
  }
47
-
48
40
  console.log("✅ All env variables are encrypted");
49
41
  }
50
42
 
51
- // CLI support
52
- if (import.meta.main) {
53
- await checkEnvEncryption();
43
+ // CLI support — works in both Bun and Node
44
+ const isMain =
45
+ process.argv[1] === import.meta.url.replace("file://", "") ||
46
+ // biome-ignore lint/correctness/noUndeclaredVariables: <optional check>
47
+ (typeof Bun !== "undefined" && import.meta.main);
48
+
49
+ if (isMain) {
50
+ checkEnvEncryption();
54
51
  }