add ui build folder
This commit is contained in:
parent
08961f692b
commit
58a193455a
6 changed files with 17 additions and 31 deletions
|
|
@ -12,37 +12,20 @@ export function rebaseUIFiles(pack_folder: string) {
|
|||
|
||||
if (!fs.existsSync(targetDir)) return
|
||||
|
||||
const processDirectory = (currentDir: string) => {
|
||||
const entries = fs.readdirSync(currentDir, { withFileTypes: true })
|
||||
for (const relativePath of ui) {
|
||||
const fullPath = path.join(targetDir, relativePath)
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(currentDir, entry.name)
|
||||
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
|
||||
try {
|
||||
const fileContent = fs.readFileSync(fullPath, "utf-8")
|
||||
const parsedData = parse(fileContent)
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
processDirectory(fullPath)
|
||||
|
||||
if (fs.readdirSync(fullPath).length === 0) {
|
||||
fs.rmdirSync(fullPath)
|
||||
}
|
||||
} else if (entry.isFile()) {
|
||||
const relativePath = fullPath.replace(targetDir + path.sep, "")
|
||||
const normalizedPath = relativePath.split(path.sep).join("/")
|
||||
|
||||
if (ui.has(normalizedPath)) {
|
||||
try {
|
||||
const fileContent = fs.readFileSync(fullPath, "utf-8")
|
||||
const parsedData = parse(fileContent)
|
||||
|
||||
if (parsedData !== undefined) {
|
||||
fs.writeFileSync(fullPath, JSON.stringify(parsedData, null, 4), "utf-8")
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Parser error: ${fullPath}`, error)
|
||||
}
|
||||
if (parsedData !== undefined) {
|
||||
fs.writeFileSync(fullPath, JSON.stringify(parsedData, null, 4), "utf-8")
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Parser error: ${fullPath}`, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processDirectory(targetDir)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ export const isBuildMode = options["build"] ?? config.compiler?.enabled ?? false
|
|||
export const isLinkMode = options["link"] ?? config.compiler?.autoImport ?? false
|
||||
export const unLinked = options["unlink"] ?? !(config.compiler?.autoImport ?? true)
|
||||
export const buildFolder = config.compiler?.buildFolder || "build"
|
||||
export const uiBuildFolder = config.compiler?.uiBuildFolder || "asajs"
|
||||
|
||||
export const bindingFuntions = config.binding_functions
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { RandomString, ResolveBinding } from "./Utils.js"
|
|||
import { RandomNamespace } from "../compilers/Random.js"
|
||||
|
||||
import util from "node:util"
|
||||
import { config } from "../compilers/Configuration.js"
|
||||
import { config, uiBuildFolder } from "../compilers/Configuration.js"
|
||||
|
||||
interface ExtendUI {
|
||||
name: string
|
||||
|
|
@ -57,7 +57,7 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
|||
this.namespace = namespace || RandomNamespace()
|
||||
|
||||
if (!path)
|
||||
this.path = `asajs/${this.namespace}${config.compiler?.fileExtension ? (config.compiler.fileExtension.startsWith(".") ? config.compiler.fileExtension : `.${config.compiler.fileExtension}`) : ".json"}`
|
||||
this.path = `${uiBuildFolder}/${this.namespace}${config.compiler?.fileExtension ? (config.compiler.fileExtension.startsWith(".") ? config.compiler.fileExtension : `.${config.compiler.fileExtension}`) : ".json"}`
|
||||
else this.path = path
|
||||
|
||||
this.extendable = this.name.search("/") === -1
|
||||
|
|
|
|||
Reference in a new issue