Add initial pack definitions

This commit is contained in:
Eldritch-Oliver 2025-10-09 02:03:18 -06:00
parent 5b9e808ea9
commit 8f206baf46
5 changed files with 146 additions and 1 deletions

7
.gitignore vendored
View file

@ -13,3 +13,10 @@ jspm_packages/
.env.test.local .env.test.local
.env.production.local .env.production.local
.env.local .env.local
# Ignore all of the binaries and stuff that gets built for Foundry from the raw
# JSON data because it's annoying seeing it in my git changes when it isn't actually
# needed.
/packs/**/*
!/packs/**/*/
!/packs/**/*.json

View file

@ -7,6 +7,8 @@
"eslint": "^9.16.0" "eslint": "^9.16.0"
}, },
"scripts": { "scripts": {
"data:build": "node scripts/buildCompendia.mjs",
"data:extract": "node scripts/extractCompendia.mjs",
"link": "node scripts/linkFoundry.mjs", "link": "node scripts/linkFoundry.mjs",
"lint": "eslint --fix", "lint": "eslint --fix",
"lint:nofix": "eslint" "lint:nofix": "eslint"

View file

@ -0,0 +1,36 @@
import { existsSync } from "fs";
import { readFile } from "fs/promises";
import { join } from "path";
import { compilePack } from "@foundryvtt/foundryvtt-cli";
import { pathToFileURL } from "url";
export async function buildCompendia() {
const manifest = JSON.parse(await readFile(`./system.json`, `utf-8`));
if (!manifest.packs || manifest.packs.length === 0) {
console.log(`No compendium packs defined`);
process.exit(0);
};
console.log(`Packing compendia`);
for (const compendium of manifest.packs) {
console.debug(`Packing ${compendium.label} (${compendium.name})`);
let src = join(process.cwd(), compendium.path, `_source`);
if (!existsSync(src)) {
console.warn(`${compendium.path} doesn't exist, skipping.`)
continue;
};
await compilePack(
src,
join(process.cwd(), compendium.path),
{ recursive: true },
);
console.debug(`Finished packing compendium: ${compendium.name}`);
};
console.log(`Finished packing all compendia`)
};
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
buildCompendia();
};

View file

@ -0,0 +1,31 @@
import { readFile } from "fs/promises";
import { join } from "path";
import { extractPack } from "@foundryvtt/foundryvtt-cli";
import { pathToFileURL } from "url";
export async function extractCompendia() {
const manifest = JSON.parse(await readFile(`./system.json`, `utf-8`));
if (!manifest.packs || manifest.packs.length === 0) {
console.log(`No compendium packs defined`);
process.exit(0);
};
console.log(`Extracting compendia`);
for (const compendium of manifest.packs) {
console.debug(`Unpacking ${compendium.label} (${compendium.name})`);
let src = join(process.cwd(), compendium.path, `_source`);
await extractPack(
join(process.cwd(), compendium.path),
src,
{ recursive: true },
);
console.debug(`Finished unpacking compendium: ${compendium.name}`);
};
console.log(`Finished unpacking all compendia`);
};
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
extractCompendia();
};

View file

@ -53,5 +53,74 @@
"skill": {}, "skill": {},
"weapon": {} "weapon": {}
} }
},
"packs": [
{
"name": "protection",
"label": "Armour & Shields",
"system": "ripcrypt",
"path": "packs/protection",
"type": "Item",
"ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
} }
},
{
"name": "weapons",
"label": "Weapons & Ammo",
"system": "ripcrypt",
"path": "packs/weapons",
"type": "Item",
"ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
},
{
"name": "skills",
"label": "Skills",
"system": "ripcrypt",
"path": "packs/skills",
"type": "Item",
"ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
},
{
"name": "geist",
"label": "Geist",
"system": "ripcrypt",
"path": "packs/geist",
"type": "Actor",
"ownership": {
"PLAYER": "NONE",
"ASSISTANT": "OWNER"
}
}
],
"packFolders": [
{
"name": "RipCrypt Sprint Start",
"color": "#04262a",
"sorting": "m",
"folders": [
{
"name": "Character Options",
"color": "#06393f",
"sorting": "m",
"folders": [],
"packs": [
"protection",
"weapons",
"skills"
]
}
],
"packs": [
"geist"
]
}
]
} }