@constatic/base 0.0.1-beta.2 → 0.0.1-beta.4
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/bootstrap.d.ts +1 -0
- package/dist/bootstrap.js +1 -1
- package/dist/env.d.ts +5 -0
- package/dist/env.js +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/modules.js +3 -2
- package/package.json +2 -1
package/dist/bootstrap.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface BootstrapOptions extends CustomClientOptions {
|
|
|
8
8
|
beforeLoad?(client: Client<boolean>): Promise<void>;
|
|
9
9
|
modules?: string[];
|
|
10
10
|
loadLogs?: boolean;
|
|
11
|
+
env?: Record<string, string | undefined>;
|
|
11
12
|
}
|
|
12
13
|
export declare function bootstrap(options: BootstrapOptions): Promise<{
|
|
13
14
|
client: Client<boolean>;
|
package/dist/bootstrap.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createClient } from "./client.js";
|
|
|
4
4
|
import { ConstaticError } from "./error.js";
|
|
5
5
|
import { loadModules } from "./modules.js";
|
|
6
6
|
async function bootstrap(options) {
|
|
7
|
-
const token = options.token ?? process.env
|
|
7
|
+
const token = options.token ?? options.env?.BOT_TOKEN ?? process.env?.BOT_TOKEN;
|
|
8
8
|
if (!token)
|
|
9
9
|
throw new ConstaticError("The application token was not provided!");
|
|
10
10
|
const app = ConstaticApp.getInstance();
|
package/dist/env.d.ts
ADDED
package/dist/env.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/env.ts
|
|
2
|
+
import { format, styleText } from "node:util";
|
|
3
|
+
async function validateEnv(schema) {
|
|
4
|
+
const result = await schema["~standard"].validate(process.env);
|
|
5
|
+
if (result.issues) {
|
|
6
|
+
const a = result.issues.map((issue) => {
|
|
7
|
+
return format(styleText("red", "✖︎ ENV VAR %s ➜ %s"), styleText("bold", issue.path?.join(".") ?? ""), styleText("gray", issue.message));
|
|
8
|
+
});
|
|
9
|
+
console.log(a.join(`
|
|
10
|
+
`));
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
console.log(styleText("dim", "☰ Environment variables validated ✓"));
|
|
14
|
+
return result.value;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
validateEnv
|
|
18
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/modules.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// src/modules.ts
|
|
2
2
|
import { glob } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
3
4
|
async function loadModules(meta, modules = []) {
|
|
4
|
-
const exclude = modules.filter((
|
|
5
|
+
const exclude = modules.filter((path2) => path2.charAt(0) == "!").map((path2) => path2.slice(1));
|
|
5
6
|
const filepaths = await Array.fromAsync(glob(modules, { cwd: meta.dirname, exclude }));
|
|
6
|
-
const promises = filepaths.map((filepath) => import(meta.
|
|
7
|
+
const promises = filepaths.map((filepath) => import(path.join(meta.dirname, filepath)).then((imported) => ({
|
|
7
8
|
module: imported,
|
|
8
9
|
filepath
|
|
9
10
|
})));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constatic/base",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@constatic/config": "*",
|
|
21
|
+
"@standard-schema/spec": "^1.0.0",
|
|
21
22
|
"typescript": "^5.9.3"
|
|
22
23
|
},
|
|
23
24
|
"exports": {
|