@powerhousedao/config 6.0.0-dev.12 → 6.0.0-dev.121
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 +968 -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 +10 -82
- 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 +39 -117
- package/tsconfig.json +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/config",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.121",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"private": false,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@
|
|
27
|
+
"@powerhousedao/shared": "6.0.0-dev.121"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"tsc": "tsc",
|
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,126 +12,24 @@ 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";
|
|
16
|
+
export type {
|
|
17
|
+
PHPackageProvider,
|
|
18
|
+
PowerhousePackage,
|
|
19
|
+
} from "@powerhousedao/shared";
|
|
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
|
-
};
|
|
77
|
-
|
|
78
|
-
const DEFAULT_DOCUMENT_MODELS_DIR = "./document-models";
|
|
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
|
-
};
|
|
101
|
-
|
|
102
|
-
export type Module = {
|
|
103
|
-
id: string;
|
|
104
|
-
name: string;
|
|
105
|
-
documentTypes: string[];
|
|
106
|
-
};
|
|
22
|
+
export const DEFAULT_REGISTRY_URL = "https://registry.prod.vetra.io";
|
|
107
23
|
|
|
108
|
-
export
|
|
109
|
-
id: string;
|
|
110
|
-
name: string;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export type Publisher = {
|
|
114
|
-
name: string;
|
|
115
|
-
url: string;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export type PowerhouseManifest = {
|
|
119
|
-
name: string;
|
|
120
|
-
description: string;
|
|
121
|
-
category: string;
|
|
122
|
-
publisher: Publisher;
|
|
123
|
-
documentModels: DocumentModelModule[];
|
|
124
|
-
editors: Module[];
|
|
125
|
-
apps: Module[];
|
|
126
|
-
subgraphs: Module[];
|
|
127
|
-
importScripts: Module[];
|
|
128
|
-
};
|
|
24
|
+
export { DEFAULT_CONFIG } from "@powerhousedao/shared/clis";
|
|
129
25
|
|
|
130
|
-
export type
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
26
|
+
export type {
|
|
27
|
+
DocumentModelModule,
|
|
28
|
+
Module,
|
|
29
|
+
PartialPowerhouseManifest,
|
|
30
|
+
PowerhouseManifest,
|
|
31
|
+
Publisher,
|
|
32
|
+
} from "@powerhousedao/shared";
|
|
135
33
|
|
|
136
34
|
export type VetraProcessorConfigType = {
|
|
137
35
|
interactive?: boolean;
|
|
@@ -139,4 +37,28 @@ export type VetraProcessorConfigType = {
|
|
|
139
37
|
driveId: string;
|
|
140
38
|
};
|
|
141
39
|
|
|
40
|
+
export function resolveRegistryConfig(
|
|
41
|
+
config: PowerhouseConfig,
|
|
42
|
+
env: Record<string, string | undefined> = {},
|
|
43
|
+
): {
|
|
44
|
+
registryUrl: string | undefined;
|
|
45
|
+
packageNames: string[];
|
|
46
|
+
} {
|
|
47
|
+
let registryUrl = config.packageRegistryUrl;
|
|
48
|
+
let packageNames =
|
|
49
|
+
config.packages
|
|
50
|
+
?.filter((p) => p.provider === "registry")
|
|
51
|
+
.map((p) => p.packageName) ?? [];
|
|
52
|
+
|
|
53
|
+
// Env vars override config
|
|
54
|
+
if (env.PH_REGISTRY_URL) {
|
|
55
|
+
registryUrl = env.PH_REGISTRY_URL;
|
|
56
|
+
}
|
|
57
|
+
if (env.PH_REGISTRY_PACKAGES) {
|
|
58
|
+
packageNames = env.PH_REGISTRY_PACKAGES.split(",").map((p) => p.trim());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { registryUrl, packageNames };
|
|
62
|
+
}
|
|
63
|
+
|
|
142
64
|
export const VETRA_PROCESSOR_CONFIG_KEY = "VetraConfig";
|