-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrepl-init.ts
More file actions
54 lines (44 loc) · 1.38 KB
/
repl-init.ts
File metadata and controls
54 lines (44 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
// Display formatting constants
const COLUMN_WIDTH = 20;
const COLUMNS_PER_ROW = 3;
// Note: These relative paths are designed to be run from the project root
import * as pkg from "./pkg/@eser/codebase/package/mod.ts";
import * as mod from "./pkg/mod.ts";
// TODO(@eser) get dependency injection container entries instead of this
await (async () => {
// const env = await config.dotenv.load();
// Load package configuration from current directory
const packageConfig = await pkg.tryLoad({ baseDir: "." });
const variables: Record<string, unknown> = {
...mod,
packageConfig,
// env,
};
const vars = () => {
console.log(
"\n%cpredefined variables\n--------------------",
"font-weight: bold",
);
console.log(
`- ${
Object.keys(variables).map((x, i) =>
`${x.padEnd(COLUMN_WIDTH, " ")}${
i % COLUMNS_PER_ROW === COLUMNS_PER_ROW - 1 ? "\n" : ""
}`
).join("- ")
}`,
);
console.log();
};
variables["vars"] = vars;
for (const [key, value] of Object.entries(variables)) {
// @ts-ignore globalThis type check
globalThis[key] = value;
}
console.log(
`%ceserstack REPL, version ${packageConfig?.version?.value ?? "unknown"}`,
"color: #00ff00",
);
vars();
})();