workin on config stuff and interface things

This commit is contained in:
2026-04-26 20:05:36 -04:00
parent b89bfa5315
commit 0fecb99e8e
4 changed files with 46 additions and 6 deletions
+6 -5
View File
@@ -1,6 +1,7 @@
import { DockerSC } from "./src/interface/docker";
import { SC_DOCKER } from "./src/interface/docker";
import './src/interface/config'
// const containers = await DockerSC.PS();
// containers.forEach(container => {
// console.log(`Name: ${container.Names}`)
// });
const containers = await DockerSC.PS();
containers.forEach(container => {
console.log(`Name: ${container.Names}`)
});
+38
View File
@@ -0,0 +1,38 @@
import z, { config } from "zod";
const DEFAULT_CONFIG_PATH = "../../config.soupclown.json";
const hostConfigSchema = z.object({
services: z.map(z.string(), z.unknown()),
})
const CONFIG_SCHEMA = z.object({
v: z.literal('v1'),
config: z.union([
hostConfigSchema,
]),
});
export type CONFIG_SCHEMA_T = z.infer<typeof CONFIG_SCHEMA>
async function _loadConfig(path = DEFAULT_CONFIG_PATH){
const configFile = Bun.file(path);
let fileJsonData: any = null;
try{
fileJsonData = await configFile.json();
}catch(e){
console.error('failed to parse json IG')
}
const configParseJsonResult = CONFIG_SCHEMA.safeParse(fileJsonData);
if(!configParseJsonResult.success){
throw "Fuck";
}
return configParseJsonResult.data as CONFIG_SCHEMA_T;
}
export const SC_CONFIG = _loadConfig();
+1 -1
View File
@@ -34,6 +34,6 @@ async function PS (){
return containerData;
}
export const DockerSC = {
export const SC_DOCKER = {
PS,
}
+1
View File
@@ -0,0 +1 @@
{ "name": "my-package" }