fix: Have modules extend Module and we use a union of Module and CustomModule for module-v1

This commit is contained in:
Gerald Pinder 2024-10-13 19:15:17 -04:00
parent 69a9e2cc2f
commit 98d48fe2e1
2 changed files with 96 additions and 94 deletions

View file

@ -21,15 +21,16 @@ for (const module of modules) {
text = text // add `...ModuleDefaults;` after the model type
.split("\n")
.flatMap(line => {
if (line.trimStart().startsWith(`type: "${module.name}"`)) {
return [
line,
'',
' ...ModuleDefaults; // added by fetchModuleSchemas.js',
]
} else {
return line;
}
return line.replace(/model ([A-Za-z]+) {/, "model $1 extends Module {");
// if (line.trimStart().startsWith(`type: "${module.name}"`)) {
// return [
// line,
// '',
// ' ...ModuleDefaults; // added by fetchModuleSchemas.js',
// ]
// } else {
// return line;
// }
})
.join('\n')
@ -42,4 +43,4 @@ for (const module of modules) {
fs.writeFileSync(`${modulesDir}/index.tsp`,
moduleImports.map(m => `import "./${m}";`).join("\n") + `
alias RepoModule = ${moduleModels.map(m => `${m}Module`).join(" | ")};`
)
)