Skip to content

Commit

Permalink
Check subdirectories when processing UUID redirects during build (fou…
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam authored Dec 9, 2024
1 parent 05842da commit 7b9977a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build/uuid-redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"Compendium.pf2e.feat-effects.Item.AclYG5JuBFrjCY3I": "Compendium.pf2e.feat-effects.Item.Effect: Divine Weapon",
"Compendium.pf2e.feat-effects.Item.AJlunjfAIOq2Sg0p": "Compendium.pf2e.feat-effects.Item.Effect: Endemic Herbs",
"Compendium.pf2e.feat-effects.Item.aqnx6IDcB7ARLxS5": "Compendium.pf2e.feat-effects.Item.Effect: Wyrmblessed Blood Magic",
"Compendium.pf2e.feat-effects.Item.aWOvmdaTK1jS3H72": "Compendium.pf2e.feat-effects.Item.Effect: Lost in the Crowd",
"Compendium.pf2e.feat-effects.Item.aWOvmdaTK1jS3H72": "Compendium.pf2e.feat-effects.Item.Effect: Lost in the Crowd",
"Compendium.pf2e.feat-effects.Item.bIU1q05vzkKBtFj2": "Compendium.pf2e.feat-effects.Item.Effect: Divine Infusion",
"Compendium.pf2e.feat-effects.Item.bl4HXm1e4NQ0iJs5": "Compendium.pf2e.feat-effects.Item.Effect: Sanctify Armament",
"Compendium.pf2e.feat-effects.Item.bliWctLi7jlKUTUe": "Compendium.pf2e.feat-effects.Item.Effect: Endemic Herbs",
Expand Down
67 changes: 57 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@sveltejs/vite-plugin-svelte": "^4.0.1",
"@types/eslint__js": "^8.42.3",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.14",
"@types/jquery": "^3.5.32",
"@types/jsdom": "^21.1.7",
Expand Down Expand Up @@ -62,6 +63,7 @@
"jest-each": "^29.7.0",
"js-angusj-clipper": "^1.3.1",
"jsdom": "^25.0.1",
"node-glob": "^1.2.0",
"peggy": "^4.1.1",
"pixi.js": "^7.4.2",
"prettier": "^3.3.3",
Expand Down
13 changes: 9 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { svelte as sveltePlugin } from "@sveltejs/vite-plugin-svelte";
import { execSync } from "child_process";
import esbuild from "esbuild";
import fs from "fs-extra";
import Glob from "glob";
import path from "path";
import Peggy from "peggy";
import * as Vite from "vite";
Expand All @@ -25,10 +26,14 @@ function getUuidRedirects(): Record<CompendiumUUID, CompendiumUUID> {
for (const [from, to] of Object.entries<string>(redirectJSON)) {
const [, , pack, documentType, name] = to.split(".", 5);
const packDir = systemJSON.packs.find((p) => p.type === documentType && p.name === pack)?.path;
if (!packDir) throw new Error(`Failure looking up pack JSON for ${to}`);
const docJSON = JSON.parse(
fs.readFileSync(path.resolve(__dirname, `${packDir}/${sluggify(name)}.json`), "utf-8"),
);
const dirPath = path.resolve(__dirname, packDir ?? "");
const filename = `${sluggify(name)}.json`;
const jsonPath = fs.existsSync(path.resolve(dirPath, filename))
? path.resolve(dirPath, filename)
: Glob.sync(path.resolve(dirPath, "**", filename)).at(0);
if (!jsonPath) throw new Error(`Failure looking up pack JSON for ${to}`);
console.log(jsonPath);
const docJSON = JSON.parse(fs.readFileSync(jsonPath, "utf-8"));
const id = docJSON._id;
if (!id) throw new Error(`No UUID redirect match found for ${documentType} ${name} in ${pack}`);
redirectJSON[from] = `Compendium.pf2e.${pack}.${documentType}.${id}`;
Expand Down

0 comments on commit 7b9977a

Please sign in to comment.