From 31ae9cf6bfc365e41e80bf79443fce9fecf299db Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sun, 13 Oct 2024 21:01:35 -0400 Subject: [PATCH] fix: Remove type from ModuleDefaults, combine unions --- fetchModuleSchemas.js | 2 +- src-tsp/main.tsp | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/fetchModuleSchemas.js b/fetchModuleSchemas.js index 3c72356..0f415f5 100644 --- a/fetchModuleSchemas.js +++ b/fetchModuleSchemas.js @@ -21,7 +21,7 @@ for (const module of modules) { text = text // add `...ModuleDefaults;` after the model type .split("\n") .flatMap(line => { - return line.replace(/model ([A-Za-z]+) {/, "model $1 extends Module {"); + return line.replace(/model ([A-Za-z]+) {/, "model $1 extends ModuleDefaults {"); // if (line.trimStart().startsWith(`type: "${module.name}"`)) { // return [ // line, diff --git a/src-tsp/main.tsp b/src-tsp/main.tsp index 9fb8a2e..f2c82a4 100644 --- a/src-tsp/main.tsp +++ b/src-tsp/main.tsp @@ -53,7 +53,7 @@ model Recipe { * * Each item in this list should have at least a `type:` or be specified to be included from an external file in the `recipes/` directory with `from-file:`. */ - modules: Array; + modules: Array; } @jsonSchema("stage-list-v1.json") @@ -82,7 +82,7 @@ model Stage { /** * The list of modules to execute. The exact same syntax used by the main recipe `modules:` property. */ - modules: Array; + modules: Array; } @jsonSchema("module-list-v1.json") @@ -92,17 +92,11 @@ model ModuleList { * * Each item in this list should have at least a `type:` or be specified to be included from an external file in the `recipes/` directory with `from-file:`. */ - modules: Array; + modules: Array; } @jsonSchema("module-v1.json") -union ModuleType { - normal: NormalModules, - custom: CustomModule, -} - -@discriminator("type") -union NormalModules { +union Module { akmods: AkmodsModule, bling: BlingModule, brew: BrewModule, @@ -120,13 +114,11 @@ union NormalModules { signing: SigningModule, systemd: SystemdModule, yafti: YaftiModule, + custom: CustomModule, } @discriminator("type") -model Module { - /** This is not a built-in module. */ - type: string; - +model ModuleDefaults { /** Whether to disabling caching for this layer. * https://blue-build.org/reference/module/#no-cache-optional */