Various fixes for official release

This commit is contained in:
2026-06-08 22:20:44 +02:00
parent 7623123bb5
commit 3851a38c9f
108 changed files with 1011 additions and 538 deletions
+25 -8
View File
@@ -1,38 +1,55 @@
import { extractPack, compilePack } from '@foundryvtt/foundryvtt-cli';
import { promises as fs } from 'fs';
import { ClassicLevel } from 'classic-level';
import fs from 'fs';
import path from 'path';
const { readdir, rm, mkdir, unlink } = fs.promises;
const MODULE_ID = process.cwd();
export class CompendiumsManager {
static async packToDistDir(srcDir = 'packs_src', distDir = 'packs-system', mode = 'yaml') {
const yaml = mode === 'yaml';
const packs = await fs.readdir('./' + srcDir);
const packs = await readdir('./' + srcDir);
for (const pack of packs) {
if (pack === '.gitattributes') continue;
const target = `${MODULE_ID}/${distDir}/${pack}`;
await rm(target, { recursive: true, force: true });
console.log('Packing ' + pack);
await compilePack(
`${MODULE_ID}/${srcDir}/${pack}`,
`${MODULE_ID}/${distDir}/${pack}`,
{ yaml }
target,
{ yaml, log: true }
);
// CLI bundles classic-level@1.x — compact with v3 for Foundry V14 compat
const db = new ClassicLevel(target, { keyEncoding: 'utf8', valueEncoding: 'json', createIfMissing: false });
await db.open();
const fwd = db.keys({ limit: 1, fillCache: false });
const firstKey = await fwd.next();
await fwd.close();
const bwd = db.keys({ limit: 1, reverse: true, fillCache: false });
const lastKey = await bwd.next();
await bwd.close();
if (firstKey && lastKey) {
await db.compactRange(firstKey, lastKey, { keyEncoding: 'utf8' });
}
await db.close();
}
}
static async unpackToSrcDir(srcDir = 'packs_src', distDir = 'packs-system', mode = 'yaml') {
const yaml = mode === 'yaml';
const packs = await fs.readdir('./' + distDir);
const packs = await readdir('./' + distDir);
for (const pack of packs) {
if (pack === '.gitattributes') continue;
if (pack === '.directory') continue;
if (pack.endsWith('.db')) continue;
console.log('Unpacking ' + pack);
const directory = `./${srcDir}/${pack}`;
await fs.mkdir(directory, { recursive: true });
await mkdir(directory, { recursive: true });
try {
for (const file of await fs.readdir(directory)) {
await fs.unlink(path.join(directory, file));
for (const file of await readdir(directory)) {
await unlink(path.join(directory, file));
}
} catch (error) {
if (error.code === 'ENOENT') console.log('No files inside of ' + pack);
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""Extract Machine Gods of the Noxian Expanse rules PDF to plain text."""
import fitz
import sys
import re
from pathlib import Path
RULES_PDF = Path("rules/Machine Gods of the Noxian Expanse - Core Rules BETA 3.pdf")
OUTPUT_TXT = Path("rules/rules_full.txt")
def extract_pdf_text(pdf_path: Path) -> str:
doc = fitz.open(str(pdf_path))
pages = []
for i, page in enumerate(doc):
text = page.get_text("text")
pages.append(f"===== PAGE {i+1} =====\n{text}")
doc.close()
return "\n\n".join(pages)
def main():
if not RULES_PDF.exists():
print(f"Error: {RULES_PDF} not found", file=sys.stderr)
sys.exit(1)
print(f"Extracting {RULES_PDF}...")
text = extract_pdf_text(RULES_PDF)
OUTPUT_TXT.write_text(text, encoding="utf-8")
print(f"Done — {len(text)} chars written to {OUTPUT_TXT}")
print(f"Total pages extracted: {text.count('===== PAGE')}")
if __name__ == "__main__":
main()