-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: From now on each release of PF2e Workbench will include the lat…
…est versions of all V9-compatible macros from https://gitlab.com/symonsch/my-foundryvtt-macros/-/tree/main/PF2e They can be found in the asymonous-benefactor-macros pack, with the express permission of said asymonous^H^H^H^H^H^H^H^H^Hanonymous (and colorless) benefactor. Attribution for the macros can normally be found inside each macro, and the source url for each macro is added at the end of the file.
- Loading branch information
Showing
10 changed files
with
263 additions
and
11,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "submodules/my-foundryvtt-macros"] | ||
path = submodules/my-foundryvtt-macros | ||
url = https://gitlab.com/symonsch/my-foundryvtt-macros.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//This script has been dreadfully hacked from the original at https://github.com/CarlosFdez/pf2e-persistent-damage/blob/master/build-packs.ts and is, like the original, provided under the [ISC license](https://www.isc.org/licenses/) | ||
|
||
import fs from "fs-extra"; | ||
import path from "path"; | ||
|
||
const asymonousSource = [ | ||
"./submodules/my-foundryvtt-macros/PF2e", | ||
"./submodules/my-foundryvtt-macros/PF2e/Contributions by others", | ||
]; | ||
const packsSource = "packs"; | ||
const workSource = "packs"; | ||
|
||
const pf2eSystemPath = (() => { | ||
const configPath = path.resolve(process.cwd(), "foundryconfig.json"); | ||
const configData = fs.existsSync(configPath) ? fs.readJSONSync(configPath) : undefined; | ||
return configData !== undefined ? path.join(configData.dataPath, "Data", "modules", configData.moduleName) : null; | ||
})(); | ||
const outDir = pf2eSystemPath ?? path.join("."); | ||
|
||
fs.mkdirsSync(path.resolve(outDir, "packs")); | ||
|
||
function randomID() { | ||
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
return Array.from(Array(16).keys()) | ||
.map(() => letters[Math.floor(Math.random() * letters.length)]) | ||
.join(""); | ||
} | ||
|
||
function copyFolder(source: string, target: string) { | ||
fs.readdirSync(source) | ||
.filter((file) => file.endsWith(".js")) | ||
.forEach((file) => { | ||
const sourcePath = decodeURIComponent(path.join(source, file)); | ||
const targetPath = decodeURIComponent(path.join(target, file)); | ||
fs.copyFileSync(sourcePath, targetPath); | ||
//Log last part of path | ||
console.log(`Copied ${path.basename(targetPath)}`); | ||
// eslint-disable-next-line | ||
fs.appendFileSync(targetPath, `\n//# source https://gitlab.com/symonsch/my-foundryvtt-macros/-/tree/main/${path.basename(path.dirname(sourcePath))}/${file}`); | ||
}); | ||
} | ||
|
||
fs.mkdirsSync(outDir + "/" + workSource + "/" + "asymonous-benefactor-macros"); | ||
copyFolder(path.resolve(".", asymonousSource[0]), path.resolve(outDir, packsSource + "/asymonous-benefactor-macros")); | ||
copyFolder(path.resolve(".", asymonousSource[1]), path.resolve(outDir, packsSource + "/asymonous-benefactor-macros")); | ||
|
||
function getFolders(dir: string) { | ||
const results = []; | ||
const folders = fs.readdirSync(workSource); | ||
for (const folder of folders) { | ||
if (fs.statSync(path.join(dir, folder)).isDirectory()) { | ||
results.push(folder); | ||
} | ||
} | ||
|
||
return results; | ||
} | ||
|
||
const folders = getFolders(packsSource); | ||
const lines: string[] = []; | ||
for (const folder of folders) { | ||
const folderPath = path.join(packsSource, folder); | ||
const files = fs.readdirSync(folderPath); | ||
for (const file of files) { | ||
const filePath = path.join(folderPath, file); | ||
if (!filePath.endsWith(".js")) { | ||
continue; | ||
} | ||
try { | ||
const contents = fs.readFileSync(filePath, { encoding: "utf8" }); | ||
// eslint-disable-next-line | ||
const json = `{"_id": "${randomID()}", "actorIds": [], "author": "${randomID()}", "command": ${JSON.stringify(contents)},"flags": {},"img":"icons/svg/dice-target.svg","name": "${path.parse(file).name}","permission": {"default": 1},"scope": "global","type": "script"}`; | ||
lines.push(json); | ||
} catch (err) { | ||
console.error(`Failed to read JSON file ${filePath}`, err); | ||
} | ||
} | ||
const result = lines.join("\n"); | ||
const file1 = path.resolve(outDir, "packs", folder + ".db"); | ||
fs.writeFileSync(file1, result, "utf8"); | ||
} |
Submodule my-foundryvtt-macros
added at
ad45a4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters