add ui build folder
This commit is contained in:
parent
08961f692b
commit
58a193455a
6 changed files with 17 additions and 31 deletions
|
|
@ -8,3 +8,4 @@ test
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
asajs.config.js
|
asajs.config.js
|
||||||
build
|
build
|
||||||
|
*.js.map
|
||||||
1
config.d.ts
vendored
1
config.d.ts
vendored
|
|
@ -15,6 +15,7 @@ export interface Config {
|
||||||
fixInventoryItemRenderer?: boolean
|
fixInventoryItemRenderer?: boolean
|
||||||
buildFolder?: string
|
buildFolder?: string
|
||||||
fileExtension?: string
|
fileExtension?: string
|
||||||
|
uiBuildFolder?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_analyzer?: {
|
ui_analyzer?: {
|
||||||
|
|
|
||||||
|
|
@ -12,37 +12,20 @@ export function rebaseUIFiles(pack_folder: string) {
|
||||||
|
|
||||||
if (!fs.existsSync(targetDir)) return
|
if (!fs.existsSync(targetDir)) return
|
||||||
|
|
||||||
const processDirectory = (currentDir: string) => {
|
for (const relativePath of ui) {
|
||||||
const entries = fs.readdirSync(currentDir, { withFileTypes: true })
|
const fullPath = path.join(targetDir, relativePath)
|
||||||
|
|
||||||
for (const entry of entries) {
|
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
|
||||||
const fullPath = path.join(currentDir, entry.name)
|
try {
|
||||||
|
const fileContent = fs.readFileSync(fullPath, "utf-8")
|
||||||
|
const parsedData = parse(fileContent)
|
||||||
|
|
||||||
if (entry.isDirectory()) {
|
if (parsedData !== undefined) {
|
||||||
processDirectory(fullPath)
|
fs.writeFileSync(fullPath, JSON.stringify(parsedData, null, 4), "utf-8")
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} 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 isLinkMode = options["link"] ?? config.compiler?.autoImport ?? false
|
||||||
export const unLinked = options["unlink"] ?? !(config.compiler?.autoImport ?? true)
|
export const unLinked = options["unlink"] ?? !(config.compiler?.autoImport ?? true)
|
||||||
export const buildFolder = config.compiler?.buildFolder || "build"
|
export const buildFolder = config.compiler?.buildFolder || "build"
|
||||||
|
export const uiBuildFolder = config.compiler?.uiBuildFolder || "asajs"
|
||||||
|
|
||||||
export const bindingFuntions = config.binding_functions
|
export const bindingFuntions = config.binding_functions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { RandomString, ResolveBinding } from "./Utils.js"
|
||||||
import { RandomNamespace } from "../compilers/Random.js"
|
import { RandomNamespace } from "../compilers/Random.js"
|
||||||
|
|
||||||
import util from "node:util"
|
import util from "node:util"
|
||||||
import { config } from "../compilers/Configuration.js"
|
import { config, uiBuildFolder } from "../compilers/Configuration.js"
|
||||||
|
|
||||||
interface ExtendUI {
|
interface ExtendUI {
|
||||||
name: string
|
name: string
|
||||||
|
|
@ -57,7 +57,7 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
||||||
this.namespace = namespace || RandomNamespace()
|
this.namespace = namespace || RandomNamespace()
|
||||||
|
|
||||||
if (!path)
|
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
|
else this.path = path
|
||||||
|
|
||||||
this.extendable = this.name.search("/") === -1
|
this.extendable = this.name.search("/") === -1
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
"outDir": "dist/js",
|
"outDir": "dist/js",
|
||||||
"declarationDir": "dist/types",
|
"declarationDir": "dist/types",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": false,
|
"sourceMap": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
|
|
|
||||||
Reference in a new issue