diff --git a/src/analyzer/generate-code.ts b/src/analyzer/generate-code.ts index dc9789b..5bc4ac6 100644 --- a/src/analyzer/generate-code.ts +++ b/src/analyzer/generate-code.ts @@ -1,6 +1,7 @@ import path from "node:path" import fs from "fs" import { config } from "../compilers/Configuration.js" +import { Type } from "../types/enums/Type.js" interface Element { file: string @@ -37,7 +38,9 @@ export function genCustomCode(pack_folder: string) { `type ${typeName} = {`, ...Object.entries(element).map(([elementPath, elementData]) => { filepaths[elementPath] = elementData.file - return ` "${elementPath}": {\n type: Type.${elementData.type.toUpperCase()},\n children: ${elementData.children ? elementData.children.map(c => `"${c}"`).join(" | ") : "string"}\n },` + const type = elementData.type.toUpperCase() + // @ts-ignore + return ` "${elementPath}": {\n type: Type.${Type[type] ? type : "PANEL"},\n children: ${elementData.children ? elementData.children.map(c => `"${c}"`).join(" | ") : "string"}\n },` }), "}", ].join("\n"), diff --git a/src/analyzer/rebaseUIFiles.ts b/src/analyzer/rebaseUIFiles.ts index da7922e..c7b0029 100644 --- a/src/analyzer/rebaseUIFiles.ts +++ b/src/analyzer/rebaseUIFiles.ts @@ -28,9 +28,7 @@ export function rebaseUIFiles(pack_folder: string) { const relativePath = fullPath.replace(targetDir + path.sep, "") const normalizedPath = relativePath.split(path.sep).join("/") - if (!ui.has(normalizedPath)) { - fs.rmSync(fullPath, { force: true }) - } else { + if (ui.has(normalizedPath)) { try { const fileContent = fs.readFileSync(fullPath, "utf-8") const parsedData = parse(fileContent) diff --git a/src/components/UI.ts b/src/components/UI.ts index c66036d..25ddcfe 100644 --- a/src/components/UI.ts +++ b/src/components/UI.ts @@ -53,11 +53,6 @@ export class UI extends Class process.exit(1) } - if (namespace && !/^\w+$/.test(namespace)) { - console.error(`The '${namespace}' cannot be used as a namespace`) - process.exit(1) - } - this.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16) this.namespace = namespace || RandomNamespace()