mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Stamp Compendiums with minimum core version on build (#1358)
This commit is contained in:
parent
01a91724ed
commit
82d39a3d70
4 changed files with 47 additions and 46 deletions
|
|
@ -15,7 +15,7 @@
|
|||
"readline": "^1.3.0",
|
||||
"pushLDBtoYML": "node ./tools/pushLDBtoYML.mjs",
|
||||
"pullYMLtoLDB": "node ./tools/pullYMLtoLDB.mjs",
|
||||
"pullYMLtoLDBBuild": "node ./tools/pullYMLtoLDBBuild.mjs",
|
||||
"pullYMLtoLDBBuild": "node ./tools/pullYMLtoLDB.mjs --build",
|
||||
"createSymlink": "node ./tools/create-symlink.mjs",
|
||||
"setup:dev": "node ./tools/dev-setup.mjs"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"description": "An unofficial implementation of the Daggerheart system",
|
||||
"version": "1.2.7",
|
||||
"compatibility": {
|
||||
"minimum": "13",
|
||||
"minimum": "13.346",
|
||||
"verified": "13.351",
|
||||
"maximum": "13"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,22 +1,26 @@
|
|||
import { compilePack } from '@foundryvtt/foundryvtt-cli';
|
||||
import readline from 'node:readline/promises';
|
||||
import { promises as fs } from 'fs';
|
||||
import systemJSON from "../system.json" with { type: "json" };
|
||||
|
||||
const MODULE_ID = process.cwd();
|
||||
const yaml = false;
|
||||
|
||||
const answer = await (async () => {
|
||||
if (process.argv.includes("--build")) return "overwrite";
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
const answer = await rl.question(
|
||||
return rl.question(
|
||||
'You are about to overwrite your current database with the saved packs/json. Write "Overwrite" if you are sure. ',
|
||||
function (answer) {
|
||||
rl.close();
|
||||
return answer;
|
||||
}
|
||||
);
|
||||
})();
|
||||
|
||||
if (answer.toLowerCase() === 'overwrite') {
|
||||
await pullToLDB();
|
||||
|
|
@ -32,7 +36,35 @@ async function pullToLDB() {
|
|||
for (const pack of packs) {
|
||||
if (pack === '.gitattributes') continue;
|
||||
console.log('Packing ' + pack);
|
||||
await compilePack(`${MODULE_ID}/src/${pack}`, `${MODULE_ID}/${pack}`, { yaml });
|
||||
await compilePack(`${MODULE_ID}/src/${pack}`, `${MODULE_ID}/${pack}`, { yaml: false, transformEntry });
|
||||
}
|
||||
|
||||
function transformEntry(entry) {
|
||||
const stats = {
|
||||
coreVersion: systemJSON.compatibility.minimum,
|
||||
systemId: "daggerheart",
|
||||
systemVersion: systemJSON.version,
|
||||
};
|
||||
|
||||
entry._stats = { ...stats };
|
||||
for (const effect of entry.effects ?? []) {
|
||||
effect._stats = {
|
||||
compendiumSource: effect._stats?.compendiumSource ?? null,
|
||||
...stats
|
||||
};
|
||||
}
|
||||
for (const item of entry.items ?? []) {
|
||||
item._stats = {
|
||||
compendiumSource: item._stats?.compendiumSource ?? null,
|
||||
...stats
|
||||
};
|
||||
for (const effect of item.effects ?? []) {
|
||||
effect._stats = {
|
||||
compendiumSource: effect._stats?.compendiumSource ?? null,
|
||||
...stats
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function deepGetDirectories(distPath) {
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
import { compilePack } from '@foundryvtt/foundryvtt-cli';
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
const MODULE_ID = process.cwd();
|
||||
const yaml = false;
|
||||
|
||||
const packs = await deepGetDirectories('./packs');
|
||||
console.log(packs);
|
||||
for (const pack of packs) {
|
||||
if (pack === '.gitattributes') continue;
|
||||
console.log('Packing ' + pack);
|
||||
await compilePack(`${MODULE_ID}/src/${pack}`, `${MODULE_ID}/${pack}`, { yaml });
|
||||
}
|
||||
|
||||
async function deepGetDirectories(distPath) {
|
||||
const dirr = await fs.readdir('src/' + distPath);
|
||||
const dirrsWithSub = [];
|
||||
for (let file of dirr) {
|
||||
const stat = await fs.stat('src/' + distPath + '/' + file);
|
||||
if (stat.isDirectory()) {
|
||||
const deeper = await deepGetDirectories(distPath + '/' + file);
|
||||
if (deeper.length > 0) {
|
||||
dirrsWithSub.push(...deeper);
|
||||
} else {
|
||||
dirrsWithSub.push(distPath + '/' + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dirrsWithSub;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue