fix: Remove type from ModuleDefaults, combine unions

This commit is contained in:
Gerald Pinder 2024-10-13 21:01:35 -04:00
parent ddd1864c3f
commit 31ae9cf6bf
2 changed files with 7 additions and 15 deletions

View file

@ -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,

View file

@ -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<ModuleType | ImportedModule>;
modules: Array<Module | ImportedModule>;
}
@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<ModuleType | ImportedModule>;
modules: Array<Module | ImportedModule>;
}
@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<ModuleType | ImportedModule>;
modules: Array<Module | ImportedModule>;
}
@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
*/