Add an importable file for the default Foundry images
This commit is contained in:
parent
b1a6752238
commit
ef63860922
4 changed files with 198 additions and 1 deletions
100
importable/findFoundryFiles.mjs
Normal file
100
importable/findFoundryFiles.mjs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
import { globSync } from "glob";
|
||||
import crypto from "crypto";
|
||||
import { createReadStream } from "fs";
|
||||
import { writeFile } from "fs/promises";
|
||||
|
||||
async function hashFile(path) {
|
||||
return new Promise((resolve) => {
|
||||
const stream = createReadStream(path);
|
||||
const hash = crypto.createHash(`sha1`);
|
||||
hash.setEncoding(`hex`);
|
||||
|
||||
stream.on(`end`, () => {
|
||||
hash.end();
|
||||
resolve(hash.read());
|
||||
});
|
||||
|
||||
stream.pipe(hash);
|
||||
});
|
||||
};
|
||||
|
||||
const skipFiles = [
|
||||
`vtt.png`,
|
||||
`vtt-512.png`,
|
||||
`anvil.png`,
|
||||
`fvtt.icns`,
|
||||
`fvtt.ico`,
|
||||
`logo-scifi.png`,
|
||||
`logo-scifi-blank.png`,
|
||||
`LICENSE`,
|
||||
];
|
||||
|
||||
const tagRenames = {
|
||||
weapons: `weapon`,
|
||||
wands: `wand`,
|
||||
swords: `sword`,
|
||||
cutlasses: `cutlass`,
|
||||
daggers: `dagger`,
|
||||
commodities: `commodity`,
|
||||
feathers: `feather`,
|
||||
dynamite: `explosive`,
|
||||
bomb: `explosive`,
|
||||
}
|
||||
|
||||
const purgeTags = new Set([
|
||||
// All of the colours
|
||||
`white`, `yellow`, `blue`, `red`, `green`, `black`, `brown`, `teal`, `silver`, `purple`, `gray`, `grey`, `orange`, `lime`, `crimson`, `magenta`, `gold`, `cyan`, `pink`, `tan`, `violet`,
|
||||
|
||||
// Terms that just suck as tags
|
||||
`simple`, `ringed`, `hollow`, `guard`, `pressure`, `gas`, `fuse`,
|
||||
`cloth`, `sharp`, `worn`,
|
||||
]);
|
||||
|
||||
async function main() {
|
||||
const imageList = globSync(`foundry/public/icons/**/*`, { nodir: true });
|
||||
const images = {};
|
||||
|
||||
for (const path of imageList) {
|
||||
if (skipFiles.some(file => path.endsWith(file))) continue;
|
||||
|
||||
const hash = await hashFile(path);
|
||||
const filename = path.split(`/`).at(-1);
|
||||
|
||||
const tags = new Set(
|
||||
path
|
||||
.replace(`foundry/public/icons/`, ``)
|
||||
.replace(/\.[a-z]+$/i, ``)
|
||||
.replaceAll(`-`, `/`)
|
||||
.split(`/`)
|
||||
.map(tag => tagRenames[tag] ?? tag)
|
||||
.filter(tag => !purgeTags.has(tag))
|
||||
);
|
||||
|
||||
images[hash] = {
|
||||
name: filename,
|
||||
tags: Array.from(tags),
|
||||
artists: [`FVTT`],
|
||||
path: path.replace(`foundry/public/`, ``),
|
||||
external: true
|
||||
};
|
||||
};
|
||||
|
||||
const data = {
|
||||
images,
|
||||
artists: {
|
||||
FVTT: { // Using a custom artist ID since this is an import anyway
|
||||
name: `Foundry Defaults`,
|
||||
links: [
|
||||
{ name: `FoundryVTT`, url: `https://foundryvtt.com` }
|
||||
]
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
await writeFile(
|
||||
`importable/foundry.json`,
|
||||
JSON.stringify(data),
|
||||
);
|
||||
};
|
||||
|
||||
main();
|
||||
1
importable/v13.351.json
Normal file
1
importable/v13.351.json
Normal file
File diff suppressed because one or more lines are too long
95
package-lock.json
generated
95
package-lock.json
generated
|
|
@ -8,6 +8,7 @@
|
|||
"@eslint/js": "^9.8.0",
|
||||
"@stylistic/eslint-plugin": "^2.6.1",
|
||||
"eslint": "^9.8.0",
|
||||
"glob": "^13.0.0",
|
||||
"globals": "^15.9.0",
|
||||
"scripts": "file:./scripts"
|
||||
}
|
||||
|
|
@ -291,6 +292,29 @@
|
|||
"url": "https://github.com/sponsors/nzakas"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/balanced-match": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",
|
||||
"integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/brace-expansion": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz",
|
||||
"integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@isaacs/balanced-match": "^4.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@seald-io/binary-search-tree": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@seald-io/binary-search-tree/-/binary-search-tree-1.0.3.tgz",
|
||||
|
|
@ -1423,6 +1447,24 @@
|
|||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/glob": {
|
||||
"version": "13.0.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.0.tgz",
|
||||
"integrity": "sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"minimatch": "^10.1.1",
|
||||
"minipass": "^7.1.2",
|
||||
"path-scurry": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/glob-parent": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
|
||||
|
|
@ -1436,6 +1478,22 @@
|
|||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/glob/node_modules/minimatch": {
|
||||
"version": "10.1.1",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz",
|
||||
"integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"@isaacs/brace-expansion": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "15.15.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz",
|
||||
|
|
@ -1873,6 +1931,16 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "11.2.5",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.5.tgz",
|
||||
"integrity": "sha512-vFrFJkWtJvJnD5hg+hJvVE8Lh/TcMzKnTgCWmtBipwI5yLX/iX+5UB2tfuyODF5E7k9xEzMdYgGqaSb1c0c5Yw==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
|
|
@ -1922,6 +1990,16 @@
|
|||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/minipass": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
|
||||
|
|
@ -2074,6 +2152,23 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/path-scurry": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.1.tgz",
|
||||
"integrity": "sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"lru-cache": "^11.0.0",
|
||||
"minipass": "^7.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
"@stylistic/eslint-plugin": "^2.6.1",
|
||||
"eslint": "^9.8.0",
|
||||
"globals": "^15.9.0",
|
||||
"scripts": "file:./scripts"
|
||||
"scripts": "file:./scripts",
|
||||
"glob": "^13.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"link": "node scripts/src/linkFoundry.mjs",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue