@powerhousedao/config 6.0.0-dev.11 → 6.0.0-dev.111
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 +895 -2
- package/dist/src/node.d.ts +2 -2
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +3 -14
- package/dist/src/node.js.map +1 -1
- package/dist/src/powerhouse.d.ts +9 -55
- package/dist/src/powerhouse.d.ts.map +1 -1
- package/dist/src/powerhouse.js +16 -22
- package/dist/src/powerhouse.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/node.ts +3 -16
- package/src/powerhouse.ts +32 -84
- package/tsconfig.json +6 -1
package/src/node.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function getConfig(path = "./powerhouse.config.json") {
|
|
6
|
-
let config: PowerhouseConfig = { ...DEFAULT_CONFIG };
|
|
7
|
-
try {
|
|
8
|
-
const configStr = readFileSync(path, "utf-8");
|
|
9
|
-
const userConfig = JSON.parse(configStr) as PowerhouseConfig;
|
|
10
|
-
config = { ...config, ...userConfig };
|
|
11
|
-
} catch {
|
|
12
|
-
console.warn("No powerhouse.config.json found, using defaults");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return config;
|
|
16
|
-
}
|
|
1
|
+
import { type PowerhouseConfig } from "@powerhousedao/shared/clis";
|
|
2
|
+
import { writeFileSync } from "node:fs";
|
|
3
|
+
export { getConfig } from "@powerhousedao/shared/clis";
|
|
17
4
|
|
|
18
5
|
export function writeConfig(
|
|
19
6
|
config: PowerhouseConfig,
|
package/src/powerhouse.ts
CHANGED
|
@@ -12,92 +12,16 @@ export type LogLevel = keyof typeof LogLevels;
|
|
|
12
12
|
export function isLogLevel(value: unknown): value is LogLevel {
|
|
13
13
|
return typeof value === "string" && value in LogLevels;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
import type { PowerhouseConfig } from "@powerhousedao/shared/clis";
|
|
16
|
+
export type {
|
|
17
|
+
PHPackageProvider,
|
|
18
|
+
PowerhousePackage,
|
|
19
|
+
} from "@powerhousedao/shared/clis";
|
|
20
|
+
export type { PowerhouseConfig };
|
|
16
21
|
|
|
17
|
-
export
|
|
18
|
-
packageName: string;
|
|
19
|
-
version?: string;
|
|
20
|
-
provider?: PHPackageProvider;
|
|
21
|
-
url?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type PowerhouseConfig = {
|
|
25
|
-
// required
|
|
26
|
-
logLevel: LogLevel;
|
|
27
|
-
documentModelsDir: string;
|
|
28
|
-
editorsDir: string;
|
|
29
|
-
processorsDir: string;
|
|
30
|
-
subgraphsDir: string;
|
|
31
|
-
importScriptsDir: string;
|
|
32
|
-
skipFormat: boolean;
|
|
33
|
-
|
|
34
|
-
// optional
|
|
35
|
-
interactive?: boolean;
|
|
36
|
-
watch?: boolean;
|
|
37
|
-
reactor?: {
|
|
38
|
-
port?: number;
|
|
39
|
-
https?:
|
|
40
|
-
| undefined
|
|
41
|
-
| boolean
|
|
42
|
-
| {
|
|
43
|
-
keyPath: string;
|
|
44
|
-
certPath: string;
|
|
45
|
-
};
|
|
46
|
-
storage?: {
|
|
47
|
-
type: "filesystem" | "memory" | "postgres" | "browser";
|
|
48
|
-
filesystemPath?: string;
|
|
49
|
-
postgresUrl?: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
auth?: {
|
|
53
|
-
enabled?: boolean;
|
|
54
|
-
guests: string[];
|
|
55
|
-
users: string[];
|
|
56
|
-
admins: string[];
|
|
57
|
-
freeEntry?: boolean;
|
|
58
|
-
};
|
|
59
|
-
switchboard?: {
|
|
60
|
-
database?: {
|
|
61
|
-
url?: string;
|
|
62
|
-
};
|
|
63
|
-
port?: number;
|
|
64
|
-
};
|
|
65
|
-
studio?: {
|
|
66
|
-
port?: number;
|
|
67
|
-
host?: string;
|
|
68
|
-
https: boolean;
|
|
69
|
-
openBrowser?: boolean;
|
|
70
|
-
};
|
|
71
|
-
packages?: PowerhousePackage[];
|
|
72
|
-
vetra?: {
|
|
73
|
-
driveId: string;
|
|
74
|
-
driveUrl: string;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
22
|
+
export const DEFAULT_REGISTRY_URL = "https://registry.prod.vetra.io";
|
|
77
23
|
|
|
78
|
-
|
|
79
|
-
const DEFAULT_EDITORS_DIR = "./editors";
|
|
80
|
-
const DEFAULT_PROCESSORS_DIR = "./processors";
|
|
81
|
-
const DEFAULT_SUBGRAPHS_DIR = "./subgraphs";
|
|
82
|
-
const DEFAULT_IMPORT_SCRIPTS_DIR = "./scripts";
|
|
83
|
-
const DEFAULT_SKIP_FORMAT = false;
|
|
84
|
-
const DEFAULT_LOG_LEVEL = "info";
|
|
85
|
-
|
|
86
|
-
export const DEFAULT_CONFIG: PowerhouseConfig = {
|
|
87
|
-
documentModelsDir: DEFAULT_DOCUMENT_MODELS_DIR,
|
|
88
|
-
editorsDir: DEFAULT_EDITORS_DIR,
|
|
89
|
-
processorsDir: DEFAULT_PROCESSORS_DIR,
|
|
90
|
-
subgraphsDir: DEFAULT_SUBGRAPHS_DIR,
|
|
91
|
-
importScriptsDir: DEFAULT_IMPORT_SCRIPTS_DIR,
|
|
92
|
-
skipFormat: DEFAULT_SKIP_FORMAT,
|
|
93
|
-
logLevel: DEFAULT_LOG_LEVEL,
|
|
94
|
-
auth: {
|
|
95
|
-
enabled: false,
|
|
96
|
-
guests: [],
|
|
97
|
-
users: [],
|
|
98
|
-
admins: [],
|
|
99
|
-
},
|
|
100
|
-
};
|
|
24
|
+
export { DEFAULT_CONFIG } from "@powerhousedao/shared/clis";
|
|
101
25
|
|
|
102
26
|
export type Module = {
|
|
103
27
|
id: string;
|
|
@@ -139,4 +63,28 @@ export type VetraProcessorConfigType = {
|
|
|
139
63
|
driveId: string;
|
|
140
64
|
};
|
|
141
65
|
|
|
66
|
+
export function resolveRegistryConfig(
|
|
67
|
+
config: PowerhouseConfig,
|
|
68
|
+
env: Record<string, string | undefined> = {},
|
|
69
|
+
): {
|
|
70
|
+
registryUrl: string | undefined;
|
|
71
|
+
packageNames: string[];
|
|
72
|
+
} {
|
|
73
|
+
let registryUrl = config.packageRegistryUrl;
|
|
74
|
+
let packageNames =
|
|
75
|
+
config.packages
|
|
76
|
+
?.filter((p) => p.provider === "registry")
|
|
77
|
+
.map((p) => p.packageName) ?? [];
|
|
78
|
+
|
|
79
|
+
// Env vars override config
|
|
80
|
+
if (env.PH_REGISTRY_URL) {
|
|
81
|
+
registryUrl = env.PH_REGISTRY_URL;
|
|
82
|
+
}
|
|
83
|
+
if (env.PH_REGISTRY_PACKAGES) {
|
|
84
|
+
packageNames = env.PH_REGISTRY_PACKAGES.split(",").map((p) => p.trim());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return { registryUrl, packageNames };
|
|
88
|
+
}
|
|
89
|
+
|
|
142
90
|
export const VETRA_PROCESSOR_CONFIG_KEY = "VetraConfig";
|