From 706f58f294e4b112ad705606084cd223a684f0fd Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sun, 13 Oct 2024 21:08:45 -0400 Subject: [PATCH] Revert "fix: Remove type from ModuleDefaults, combine unions" This reverts commit 31ae9cf6bfc365e41e80bf79443fce9fecf299db. --- fetchModuleSchemas.js | 2 +- src-tsp/main.tsp | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/fetchModuleSchemas.js b/fetchModuleSchemas.js index 0f415f5..3c72356 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 ModuleDefaults {"); + return line.replace(/model ([A-Za-z]+) {/, "model $1 extends Module {"); // if (line.trimStart().startsWith(`type: "${module.name}"`)) { // return [ // line, diff --git a/src-tsp/main.tsp b/src-tsp/main.tsp index f2c82a4..9fb8a2e 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,11 +92,17 @@ 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 Module { +union ModuleType { + normal: NormalModules, + custom: CustomModule, +} + +@discriminator("type") +union NormalModules { akmods: AkmodsModule, bling: BlingModule, brew: BrewModule, @@ -114,11 +120,13 @@ union Module { signing: SigningModule, systemd: SystemdModule, yafti: YaftiModule, - custom: CustomModule, } @discriminator("type") -model ModuleDefaults { +model Module { + /** This is not a built-in module. */ + type: string; + /** Whether to disabling caching for this layer. * https://blue-build.org/reference/module/#no-cache-optional */