mirror of
https://github.com/thepeacockproject/Peacock
synced 2025-03-27 11:12:44 +01:00
chore: small refactor to add itemsize tool
This commit is contained in:
parent
d47fda4d2b
commit
46e66c32c9
@ -16,6 +16,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const fs = require("fs")
|
||||||
|
const { execSync } = require("child_process")
|
||||||
|
|
||||||
// Usage:
|
// Usage:
|
||||||
// - Go to https://glaciermodding.org/rpkg/ and click "Download latest CLI"
|
// - Go to https://glaciermodding.org/rpkg/ and click "Download latest CLI"
|
||||||
// - Extract contents of downloaded zip file to packaging/add_itemsize/
|
// - Extract contents of downloaded zip file to packaging/add_itemsize/
|
||||||
@ -24,12 +27,12 @@
|
|||||||
// - either H2 or H3 Runtime path seem to work for Scpc Game Version
|
// - either H2 or H3 Runtime path seem to work for Scpc Game Version
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const fs = require("fs")
|
|
||||||
const rpkgCli = `"./rpkg-cli.exe"`
|
const rpkgCli = `"./rpkg-cli.exe"`
|
||||||
const { execSync } = require("child_process")
|
|
||||||
let chunk0patches = fs
|
let chunk0patches = fs
|
||||||
.readdirSync(`${process.argv[2]}`)
|
.readdirSync(`${process.argv[2]}`)
|
||||||
.filter((fn) => fn.includes("chunk0") && !fn.includes("300.rpkg"))
|
.filter((fn) => fn.includes("chunk0") && !fn.includes("300.rpkg"))
|
||||||
|
|
||||||
let gameprefix = ""
|
let gameprefix = ""
|
||||||
if (process.argv[3] === "H1") {
|
if (process.argv[3] === "H1") {
|
||||||
gameprefix = "Legacy"
|
gameprefix = "Legacy"
|
||||||
@ -66,14 +69,15 @@ async function main() {
|
|||||||
0,
|
0,
|
||||||
repofiles[0].length - 5,
|
repofiles[0].length - 5,
|
||||||
)}.json`
|
)}.json`
|
||||||
await fs.promises
|
|
||||||
.copyFile(orig, newfile)
|
try {
|
||||||
.then(function () {
|
await fs.promises.copyFile(orig, newfile)
|
||||||
console.log(`${newfile} file copied`)
|
|
||||||
})
|
console.log(`${newfile} file copied`)
|
||||||
.catch(function (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
}
|
||||||
|
|
||||||
let repochunk0 = require(`../add_itemsize/${newfile}`)
|
let repochunk0 = require(`../add_itemsize/${newfile}`)
|
||||||
|
|
||||||
for (let i = 0; i < allunlockables.length; i++) {
|
for (let i = 0; i < allunlockables.length; i++) {
|
||||||
@ -114,21 +118,21 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const jsonContent = JSON.stringify(allunlockables, null, 4)
|
const jsonContent = JSON.stringify(allunlockables, null, 4)
|
||||||
fs.writeFile(
|
try {
|
||||||
`../../static/${gameprefix}allunlockables.json`,
|
await fs.promises.writeFile(
|
||||||
jsonContent,
|
`../../static/${gameprefix}allunlockables.json`,
|
||||||
"utf8",
|
jsonContent,
|
||||||
function (err) {
|
"utf8",
|
||||||
if (err) {
|
)
|
||||||
return console.log(err)
|
|
||||||
}
|
console.log(
|
||||||
console.log(
|
`${gameprefix}allunlockables.json file updated with item sizes!`,
|
||||||
`${gameprefix}allunlockables.json file updated with item sizes!`,
|
)
|
||||||
)
|
// Might be better to have the user call this themselves, but it resolves line break inconsistencies
|
||||||
// Might be better to have the user call this themselves, but it resolves line break inconsistencies
|
execSync(`yarn prettier`)
|
||||||
execSync(`yarn prettier`)
|
} catch (error) {
|
||||||
},
|
console.log(error)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user