mirror of
https://github.com/thepeacockproject/Peacock
synced 2024-11-22 22:12:45 +01:00
Changed importing .json as text instead for performance reasons (#40)
This commit is contained in:
parent
b44774d971
commit
c37241210a
@ -197,6 +197,9 @@ const configs: Record<string, unknown> = {
|
||||
}
|
||||
|
||||
Object.keys(configs).forEach((cfg) => {
|
||||
// Parse the string into an object
|
||||
configs[cfg] = JSON.parse(configs[cfg])
|
||||
|
||||
const overridePath = join("overrides", `${cfg}.json`)
|
||||
|
||||
if (existsSync(overridePath)) {
|
||||
|
@ -66,7 +66,9 @@ import { MenuSystemDatabase, menuSystemDatabase } from "./menus/menuSystem"
|
||||
import { escalationMappings } from "./contracts/escalationMappings"
|
||||
import { parse } from "json5"
|
||||
import { userAuths } from "./officialServerAuth"
|
||||
// @ts-expect-error Ignore JSON import
|
||||
import LASTYARDBIRDSCPC from "../contractdata/SNIPER/THELASTYARDBIRD_SCPC.json"
|
||||
// @ts-expect-error Ignore JSON import
|
||||
import LEGACYFF from "../contractdata/COLORADO/FREEDOMFIGHTERSLEGACY.json"
|
||||
import { missionsInLocations } from "./contracts/missionsInLocation"
|
||||
import { createContext, Script } from "vm"
|
||||
@ -263,9 +265,10 @@ function createPeacockRequire(pluginName: string): NodeRequire {
|
||||
/**
|
||||
* Freedom Fighters for Hitman 2016 (objectives are different).
|
||||
*/
|
||||
export const _legacyBull: MissionManifest = LEGACYFF
|
||||
export const _legacyBull: MissionManifest = JSON.parse(LEGACYFF)
|
||||
|
||||
export const _theLastYardbirdScpc: MissionManifest = LASTYARDBIRDSCPC
|
||||
export const _theLastYardbirdScpc: MissionManifest =
|
||||
JSON.parse(LASTYARDBIRDSCPC)
|
||||
|
||||
export const peacockRecentEscalations: readonly string[] = [
|
||||
"35f1f534-ae2d-42be-8472-dd55e96625ea",
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* The Peacock Project - a HITMAN server replacement.
|
||||
* Copyright (C) 2021-2022 The Peacock Project Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { MissionManifest } from "../../components/types/types"
|
||||
|
||||
declare const FREEDOMFIGHTERSLEGACY: MissionManifest
|
||||
|
||||
export default FREEDOMFIGHTERSLEGACY
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* The Peacock Project - a HITMAN server replacement.
|
||||
* Copyright (C) 2021-2022 The Peacock Project Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { MissionManifest } from "../../components/types/types"
|
||||
|
||||
declare const THELASTYARDBIRD_SCPC: MissionManifest
|
||||
|
||||
export default THELASTYARDBIRD_SCPC
|
@ -27,6 +27,23 @@ await packContractsAndChallenges()
|
||||
|
||||
const { version, revisionIdent } = require("../package.json")
|
||||
|
||||
const jsonAsCompressedTextPlugin = {
|
||||
name: "jsonAsCompressedTextPlugin",
|
||||
|
||||
setup(build) {
|
||||
const fs = require("fs")
|
||||
|
||||
build.onLoad({ filter: /\.json$/ }, async (args) => {
|
||||
const text = await fs.promises.readFile(args.path)
|
||||
|
||||
return {
|
||||
contents: JSON.stringify(JSON.parse(text)),
|
||||
loader: "text",
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
await e.build({
|
||||
entryPoints: ["components/index.ts"],
|
||||
bundle: true,
|
||||
@ -59,6 +76,7 @@ await e.build({
|
||||
},
|
||||
sourcemap: "external",
|
||||
plugins: [
|
||||
jsonAsCompressedTextPlugin,
|
||||
esbuildPluginLicense({
|
||||
thirdParty: {
|
||||
output: {
|
||||
|
@ -18,7 +18,8 @@
|
||||
|
||||
import picocolors from "picocolors"
|
||||
import { packContractsAndChallenges } from "./buildTasks.mjs"
|
||||
import { createRequire } from "module"
|
||||
import { createRequire, Module } from "module"
|
||||
import { readFileSync } from "fs"
|
||||
|
||||
// this `require` instance will be hijacked by `esbuild-register` so we can load
|
||||
// TS files as if they were JS in a CommonJS environment
|
||||
@ -46,4 +47,12 @@ const { register } = require("esbuild-register/dist/node")
|
||||
|
||||
register()
|
||||
|
||||
const resolveTextFile = function (module, path) {
|
||||
const content = readFileSync(path).toString()
|
||||
|
||||
module.exports = content
|
||||
}
|
||||
|
||||
Module._extensions[".json"] = resolveTextFile
|
||||
|
||||
require("../components/index.ts")
|
||||
|
Loading…
Reference in New Issue
Block a user