fix somebug
This commit is contained in:
parent
d02d0469c3
commit
be4ceb4afe
3 changed files with 5 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import path from "node:path"
|
import path from "node:path"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import { config } from "../compilers/Configuration.js"
|
import { config } from "../compilers/Configuration.js"
|
||||||
|
import { Type } from "../types/enums/Type.js"
|
||||||
|
|
||||||
interface Element {
|
interface Element {
|
||||||
file: string
|
file: string
|
||||||
|
|
@ -37,7 +38,9 @@ export function genCustomCode(pack_folder: string) {
|
||||||
`type ${typeName} = {`,
|
`type ${typeName} = {`,
|
||||||
...Object.entries(element).map(([elementPath, elementData]) => {
|
...Object.entries(element).map(([elementPath, elementData]) => {
|
||||||
filepaths[elementPath] = elementData.file
|
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"),
|
].join("\n"),
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,7 @@ export function rebaseUIFiles(pack_folder: string) {
|
||||||
const relativePath = fullPath.replace(targetDir + path.sep, "")
|
const relativePath = fullPath.replace(targetDir + path.sep, "")
|
||||||
const normalizedPath = relativePath.split(path.sep).join("/")
|
const normalizedPath = relativePath.split(path.sep).join("/")
|
||||||
|
|
||||||
if (!ui.has(normalizedPath)) {
|
if (ui.has(normalizedPath)) {
|
||||||
fs.rmSync(fullPath, { force: true })
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
const fileContent = fs.readFileSync(fullPath, "utf-8")
|
const fileContent = fs.readFileSync(fullPath, "utf-8")
|
||||||
const parsedData = parse(fileContent)
|
const parsedData = parse(fileContent)
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,6 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
||||||
process.exit(1)
|
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.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16)
|
||||||
this.namespace = namespace || RandomNamespace()
|
this.namespace = namespace || RandomNamespace()
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue