@arkstack/common 0.16.5 → 0.16.7
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/faker.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { _ as Hash, c as abortIf, d as initializeGlobalContext, f as isClass, g as Exception, h as AppException, l as assertFound, m as RequestException, p as perPage, s as abort, u as getModel, v as Encryption } from "./utils-
|
|
1
|
+
import { _ as EnvLoader, a as env, c as nodeEnv, d as resolveRuntimeDir, f as resolveRuntimeModule, g as configLoader, h as ConfigLoader, i as discoverCommands, l as outputDir, m as CONFIG_KEY, n as appUrl, o as importFile, p as toOutputPath, r as config, s as interopDefault, t as appKey, u as rebuildOutput, v as envLoader } from "./system-XvUhJFS0.js";
|
|
2
|
+
import { _ as Hash, c as abortIf, d as initializeGlobalContext, f as isClass, g as Exception, h as AppException, l as assertFound, m as RequestException, p as perPage, s as abort, u as getModel, v as Encryption } from "./utils-CrxwQPPI.js";
|
|
3
3
|
import { Hook as Hook$1 } from "@arkstack/foundry";
|
|
4
4
|
import { Arkstack } from "@arkstack/contract";
|
|
5
5
|
import { str } from "@h3ravel/support";
|
|
@@ -3,12 +3,72 @@ import { existsSync, readdirSync } from "fs";
|
|
|
3
3
|
import { Arkstack } from "@arkstack/contract";
|
|
4
4
|
import { Arr, Obj, undot } from "@h3ravel/support";
|
|
5
5
|
import { readdirSync as readdirSync$1 } from "node:fs";
|
|
6
|
+
import { config } from "dotenv";
|
|
6
7
|
import { createRequire } from "module";
|
|
7
8
|
import path, { resolve } from "node:path";
|
|
8
|
-
import { config } from "dotenv";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
10
|
import { rm } from "node:fs/promises";
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
|
+
//#region src/EnvLoader.ts
|
|
13
|
+
/**
|
|
14
|
+
* Loads environment variables, reading the `.env` file on first access.
|
|
15
|
+
*
|
|
16
|
+
* The `.env` file is loaded lazily the first time a variable is read, so
|
|
17
|
+
* environment access never depends on a side-effect `import 'dotenv/config'`
|
|
18
|
+
* running first. Import ordering — which linters and bundlers may rewrite —
|
|
19
|
+
* could otherwise place an env-reading module before dotenv has populated
|
|
20
|
+
* `process.env`, leaving that module with default/stale values.
|
|
21
|
+
* `dotenv.config()` never overrides variables already set, so the lazy load is
|
|
22
|
+
* safe alongside other loaders.
|
|
23
|
+
*/
|
|
24
|
+
var EnvLoader = class {
|
|
25
|
+
loaded = false;
|
|
26
|
+
/**
|
|
27
|
+
* Load the `.env` file once.
|
|
28
|
+
*
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
ensureLoaded() {
|
|
32
|
+
if (this.loaded) return;
|
|
33
|
+
this.loaded = true;
|
|
34
|
+
try {
|
|
35
|
+
config({ quiet: true });
|
|
36
|
+
} catch {}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Read an environment variable, coercing booleans, numbers and `null`, and
|
|
40
|
+
* falling back to `defaultValue` when it is unset.
|
|
41
|
+
*
|
|
42
|
+
* @param name The variable name.
|
|
43
|
+
* @param defaultValue Returned when the variable is unset.
|
|
44
|
+
*/
|
|
45
|
+
get(name, defaultValue) {
|
|
46
|
+
this.ensureLoaded();
|
|
47
|
+
let val = process.env[name] ?? "";
|
|
48
|
+
if ([
|
|
49
|
+
true,
|
|
50
|
+
"true",
|
|
51
|
+
"on",
|
|
52
|
+
false,
|
|
53
|
+
"false",
|
|
54
|
+
"off"
|
|
55
|
+
].includes(val)) val = [
|
|
56
|
+
true,
|
|
57
|
+
"true",
|
|
58
|
+
"on"
|
|
59
|
+
].includes(val);
|
|
60
|
+
if (!isNaN(Number(val)) && typeof val !== "boolean" && typeof val !== "undefined" && val !== "") val = Number(val);
|
|
61
|
+
if (val === "") val = void 0;
|
|
62
|
+
if (val === "null") val = null;
|
|
63
|
+
val ??= defaultValue;
|
|
64
|
+
return val;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Shared environment loader backing {@link env}.
|
|
69
|
+
*/
|
|
70
|
+
const envLoader = new EnvLoader();
|
|
71
|
+
//#endregion
|
|
12
72
|
//#region src/ConfigLoader.ts
|
|
13
73
|
const CONFIG_KEY = Symbol("globalConfig");
|
|
14
74
|
globalThis[CONFIG_KEY] = {};
|
|
@@ -89,7 +149,7 @@ var ConfigLoader = class {
|
|
|
89
149
|
* @param defaultValue Returned when a string key is not found.
|
|
90
150
|
*/
|
|
91
151
|
resolve(key, defaultValue) {
|
|
92
|
-
if (typeof globalThis.env === "undefined") globalThis.env = (k, def) =>
|
|
152
|
+
if (typeof globalThis.env === "undefined") globalThis.env = (k, def) => new EnvLoader().get(k ?? "", def);
|
|
93
153
|
this.load();
|
|
94
154
|
if (typeof key === "object" && key !== null) this.store = undot(Object.assign({}, Arr.dot(this.store), Arr.dot(key)));
|
|
95
155
|
else if (typeof key === "string") return Obj.get(this.store, key, defaultValue);
|
|
@@ -101,66 +161,6 @@ var ConfigLoader = class {
|
|
|
101
161
|
*/
|
|
102
162
|
const configLoader = new ConfigLoader();
|
|
103
163
|
//#endregion
|
|
104
|
-
//#region src/EnvLoader.ts
|
|
105
|
-
/**
|
|
106
|
-
* Loads environment variables, reading the `.env` file on first access.
|
|
107
|
-
*
|
|
108
|
-
* The `.env` file is loaded lazily the first time a variable is read, so
|
|
109
|
-
* environment access never depends on a side-effect `import 'dotenv/config'`
|
|
110
|
-
* running first. Import ordering — which linters and bundlers may rewrite —
|
|
111
|
-
* could otherwise place an env-reading module before dotenv has populated
|
|
112
|
-
* `process.env`, leaving that module with default/stale values.
|
|
113
|
-
* `dotenv.config()` never overrides variables already set, so the lazy load is
|
|
114
|
-
* safe alongside other loaders.
|
|
115
|
-
*/
|
|
116
|
-
var EnvLoader = class {
|
|
117
|
-
loaded = false;
|
|
118
|
-
/**
|
|
119
|
-
* Load the `.env` file once.
|
|
120
|
-
*
|
|
121
|
-
* @returns
|
|
122
|
-
*/
|
|
123
|
-
ensureLoaded() {
|
|
124
|
-
if (this.loaded) return;
|
|
125
|
-
this.loaded = true;
|
|
126
|
-
try {
|
|
127
|
-
config({ quiet: true });
|
|
128
|
-
} catch {}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Read an environment variable, coercing booleans, numbers and `null`, and
|
|
132
|
-
* falling back to `defaultValue` when it is unset.
|
|
133
|
-
*
|
|
134
|
-
* @param name The variable name.
|
|
135
|
-
* @param defaultValue Returned when the variable is unset.
|
|
136
|
-
*/
|
|
137
|
-
get(name, defaultValue) {
|
|
138
|
-
this.ensureLoaded();
|
|
139
|
-
let val = process.env[name] ?? "";
|
|
140
|
-
if ([
|
|
141
|
-
true,
|
|
142
|
-
"true",
|
|
143
|
-
"on",
|
|
144
|
-
false,
|
|
145
|
-
"false",
|
|
146
|
-
"off"
|
|
147
|
-
].includes(val)) val = [
|
|
148
|
-
true,
|
|
149
|
-
"true",
|
|
150
|
-
"on"
|
|
151
|
-
].includes(val);
|
|
152
|
-
if (!isNaN(Number(val)) && typeof val !== "boolean" && typeof val !== "undefined" && val !== "") val = Number(val);
|
|
153
|
-
if (val === "") val = void 0;
|
|
154
|
-
if (val === "null") val = null;
|
|
155
|
-
val ??= defaultValue;
|
|
156
|
-
return val;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Shared environment loader backing {@link env}.
|
|
161
|
-
*/
|
|
162
|
-
const envLoader = new EnvLoader();
|
|
163
|
-
//#endregion
|
|
164
164
|
//#region src/system.ts
|
|
165
165
|
/**
|
|
166
166
|
* Read the .env file
|
|
@@ -472,4 +472,4 @@ const interopDefault = (imp) => {
|
|
|
472
472
|
return typeof imp === "function" ? imp : imp.default;
|
|
473
473
|
};
|
|
474
474
|
//#endregion
|
|
475
|
-
export {
|
|
475
|
+
export { EnvLoader as _, env$1 as a, nodeEnv as c, resolveRuntimeDir as d, resolveRuntimeModule as f, configLoader as g, ConfigLoader as h, discoverCommands as i, outputDir as l, CONFIG_KEY as m, appUrl as n, importFile as o, toOutputPath as p, config$1 as r, interopDefault as s, appKey as t, rebuildOutput as u, envLoader as v };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as Hash, a as use, c as abortIf, d as initializeGlobalContext, f as isClass, i as trait, l as assertFound, n as crc32, o as uses, p as perPage, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, v as Encryption } from "../utils-
|
|
1
|
+
import { _ as Hash, a as use, c as abortIf, d as initializeGlobalContext, f as isClass, i as trait, l as assertFound, n as crc32, o as uses, p as perPage, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, v as Encryption } from "../utils-CrxwQPPI.js";
|
|
2
2
|
export { Encryption, Hash, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getTraitMethods, initializeGlobalContext, isClass, perPage, trait, use, uses };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as env, f as resolveRuntimeModule, o as importFile, t as appKey } from "./system-
|
|
1
|
+
import { a as env, f as resolveRuntimeModule, o as importFile, t as appKey } from "./system-XvUhJFS0.js";
|
|
2
2
|
import { createCipheriv, createDecipheriv, createHash, randomBytes } from "node:crypto";
|
|
3
3
|
import { Arkstack } from "@arkstack/contract";
|
|
4
4
|
import path from "node:path";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/common",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core utilities, primitives, and shared infrastructure for the Arkstack ecosystem.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"selfsigned": "^2.4.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@h3ravel/support": "^2.2.
|
|
49
|
-
"arkormx": "^2.
|
|
50
|
-
"@arkstack/contract": "^0.16.
|
|
51
|
-
"@arkstack/foundry": "^0.16.
|
|
48
|
+
"@h3ravel/support": "^2.2.4",
|
|
49
|
+
"arkormx": "^2.11.4",
|
|
50
|
+
"@arkstack/contract": "^0.16.7",
|
|
51
|
+
"@arkstack/foundry": "^0.16.7"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
54
|
"@faker-js/faker": "^10.4.0"
|