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",
|
"readline": "^1.3.0",
|
||||||
"pushLDBtoYML": "node ./tools/pushLDBtoYML.mjs",
|
"pushLDBtoYML": "node ./tools/pushLDBtoYML.mjs",
|
||||||
"pullYMLtoLDB": "node ./tools/pullYMLtoLDB.mjs",
|
"pullYMLtoLDB": "node ./tools/pullYMLtoLDB.mjs",
|
||||||
"pullYMLtoLDBBuild": "node ./tools/pullYMLtoLDBBuild.mjs",
|
"pullYMLtoLDBBuild": "node ./tools/pullYMLtoLDB.mjs --build",
|
||||||
"createSymlink": "node ./tools/create-symlink.mjs",
|
"createSymlink": "node ./tools/create-symlink.mjs",
|
||||||
"setup:dev": "node ./tools/dev-setup.mjs"
|
"setup:dev": "node ./tools/dev-setup.mjs"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"description": "An unofficial implementation of the Daggerheart system",
|
"description": "An unofficial implementation of the Daggerheart system",
|
||||||
"version": "1.2.7",
|
"version": "1.2.7",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "13",
|
"minimum": "13.346",
|
||||||
"verified": "13.351",
|
"verified": "13.351",
|
||||||
"maximum": "13"
|
"maximum": "13"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,26 @@
|
||||||
import { compilePack } from '@foundryvtt/foundryvtt-cli';
|
import { compilePack } from '@foundryvtt/foundryvtt-cli';
|
||||||
import readline from 'node:readline/promises';
|
import readline from 'node:readline/promises';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
|
import systemJSON from "../system.json" with { type: "json" };
|
||||||
|
|
||||||
const MODULE_ID = process.cwd();
|
const MODULE_ID = process.cwd();
|
||||||
const yaml = false;
|
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
const answer = await (async () => {
|
||||||
input: process.stdin,
|
if (process.argv.includes("--build")) return "overwrite";
|
||||||
output: process.stdout
|
|
||||||
});
|
|
||||||
|
|
||||||
const answer = await rl.question(
|
const rl = readline.createInterface({
|
||||||
'You are about to overwrite your current database with the saved packs/json. Write "Overwrite" if you are sure. ',
|
input: process.stdin,
|
||||||
function (answer) {
|
output: process.stdout
|
||||||
rl.close();
|
});
|
||||||
return answer;
|
|
||||||
}
|
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') {
|
if (answer.toLowerCase() === 'overwrite') {
|
||||||
await pullToLDB();
|
await pullToLDB();
|
||||||
|
|
@ -32,7 +36,35 @@ async function pullToLDB() {
|
||||||
for (const pack of packs) {
|
for (const pack of packs) {
|
||||||
if (pack === '.gitattributes') continue;
|
if (pack === '.gitattributes') continue;
|
||||||
console.log('Packing ' + pack);
|
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) {
|
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