From f69a1a39bbcbb2d99ae1ef1204e60b4382cf2874 Mon Sep 17 00:00:00 2001 From: Giddy Date: Sat, 22 Oct 2022 21:47:37 +0100 Subject: [PATCH] v10 support (#44) * chore: update dependencies * feat: add Foundry v10 support (note that this drops v9 support) * 0.2.0 --- macro-item/spell/XGE_toll-the-dead.js | 6 +- module/data/spell/GiddySpell.json | 2 +- module/data/spell/__core.json | 4 +- module/js/Main.js | 28 ++++--- module/shared/SharedConsts.js | 6 +- package-lock.json | 74 ++++++++++++------ package.json | 8 +- script/build-task.js | 108 +++++++++++++------------- script/package.js | 4 +- test/schema/shared.json | 6 +- test/test-json.js | 2 +- 11 files changed, 139 insertions(+), 109 deletions(-) diff --git a/macro-item/spell/XGE_toll-the-dead.js b/macro-item/spell/XGE_toll-the-dead.js index bfbd6e9..f50ee1c 100644 --- a/macro-item/spell/XGE_toll-the-dead.js +++ b/macro-item/spell/XGE_toll-the-dead.js @@ -3,10 +3,10 @@ async function macro (args) { if (args[0].macroPass !== "preDamageRoll") return; const target = await fromUuid(args[0].targetUuids[0]); - const needsD12 = target.actor.data.data.attributes.hp.value < target.actor.data.data.attributes.hp.max; + const needsD12 = target.actor.system.attributes.hp.value < target.actor.system.attributes.hp.max; const theItem = await fromUuid(args[0].uuid); - let formula = theItem.data.data.damage.parts[0][0]; + let formula = theItem.system.damage.parts[0][0]; if (needsD12) formula = formula.replace("d8", "d12"); else formula = formula.replace("d12", "d8"); - theItem.data.data.damage.parts[0][0] = formula; + theItem.system.damage.parts[0][0] = formula; } diff --git a/module/data/spell/GiddySpell.json b/module/data/spell/GiddySpell.json index c1d0921..e6cce80 100644 --- a/module/data/spell/GiddySpell.json +++ b/module/data/spell/GiddySpell.json @@ -12,7 +12,7 @@ "name": "Collapse Astronomical Body", "source": "GiddySpell", "img": "icons/magic/earth/orb-ringed-lava-black-orange.webp", - "data": { + "system": { "actionType": "other", "damage.parts": [ [ diff --git a/module/data/spell/__core.json b/module/data/spell/__core.json index f08afca..46b0348 100644 --- a/module/data/spell/__core.json +++ b/module/data/spell/__core.json @@ -497,7 +497,7 @@ "Expire effect when character casts a spell on an enemy", "Automate effect--WIS save should be forced" ], - "data": { + "system": { "actionType": "other" }, "effects": [ @@ -567,7 +567,7 @@ { "name": "Toll the Dead", "source": "XGE", - "data": { + "system": { "damage.parts": [ [ "1d8", diff --git a/module/js/Main.js b/module/js/Main.js index 9ad121d..1f52655 100644 --- a/module/js/Main.js +++ b/module/js/Main.js @@ -46,24 +46,22 @@ class DataManager { static _getPostProcessed ({out}) { if (!out.itemMacro) return out; - out = MiscUtil.copy(out); + out = foundry.utils.deepClone(out); out.flags = out.flags || {}; out.flags.itemacro = { "macro": { - "data": { - "_id": null, - "name": "-", - "type": "script", - "author": game.userId, - "img": "icons/svg/dice-target.svg", - "scope": "global", - "command": out.itemMacro, - "folder": null, - "sort": 0, - "permission": {"default": 0}, - "flags": {}, - }, + "_id": null, + "name": "-", + "type": "script", + "author": game.userId, + "img": "icons/svg/dice-target.svg", + "scope": "global", + "command": out.itemMacro, + "folder": null, + "sort": 0, + "ownership": {"default": 0}, + "flags": {}, }, }; @@ -74,7 +72,7 @@ class DataManager { } class Api { - static init () { game.modules.get(SharedConsts.MODULE_NAME).api = this; } + static init () { game.modules.get(SharedConsts.MODULE_ID).api = this; } static pGetExpandedAddonData (opts) { return DataManager.api_pGetExpandedAddonData(opts); } } diff --git a/module/shared/SharedConsts.js b/module/shared/SharedConsts.js index cd52ef4..3168e0b 100644 --- a/module/shared/SharedConsts.js +++ b/module/shared/SharedConsts.js @@ -1,10 +1,10 @@ class SharedConsts { - static MODULE_NAME = `plutonium-addon-automation`; + static MODULE_ID = `plutonium-addon-automation`; static MODULE_TITLE = "Plutonium Addon: Automation"; - static MODULE_DIR = `./dist/${SharedConsts.MODULE_NAME}`; + static MODULE_DIR = `./dist/${SharedConsts.MODULE_ID}`; - static MODULE_PATH = `modules/${SharedConsts.MODULE_NAME}`; + static MODULE_PATH = `modules/${SharedConsts.MODULE_ID}`; static MODULE_NAME_PARENT = `plutonium`; } diff --git a/package-lock.json b/package-lock.json index 8dcd69f..ceb0cd0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,23 +1,23 @@ { "name": "plutonium-addon-automation", - "version": "0.1.7", + "version": "0.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "plutonium-addon-automation", - "version": "0.1.7", + "version": "0.2.0", "license": "MIT", "devDependencies": { - "@league-of-foundry-developers/foundry-vtt-types": "^9.269.0", - "5etools-utils": "^0.1.21", + "@league-of-foundry-developers/foundry-vtt-types": "^9.280.0", + "5etools-utils": "^0.1.23", "adm-zip-giddy": "^0.4.12", "ajv": "^8.10.0", "commander": "^9.1.0", "eslint": "^8.11.0", "express": "^4.17.3", "json-source-map": "^0.6.1", - "plutonium-utils": "^0.1.13" + "plutonium-utils": "^0.1.15" } }, "node_modules/@eslint/eslintrc": { @@ -83,9 +83,9 @@ "dev": true }, "node_modules/@league-of-foundry-developers/foundry-vtt-types": { - "version": "9.269.0", - "resolved": "https://registry.npmjs.org/@league-of-foundry-developers/foundry-vtt-types/-/foundry-vtt-types-9.269.0.tgz", - "integrity": "sha512-M/rz86decPLXet9e6+bi0dm8WSGrT/5MM1QXUMEC7Z8vfKB9Y5D61B1J5laaqb3DdjVDS1kZtQEW3/sPg3EALw==", + "version": "9.280.0", + "resolved": "https://registry.npmjs.org/@league-of-foundry-developers/foundry-vtt-types/-/foundry-vtt-types-9.280.0.tgz", + "integrity": "sha512-Dv8/+kgAnI2F5snSWcnMnZsgO/87AFyBruflluZkWDbP7Pm5qi32GlNYCDEg7HMKybzyKmgLV2qXMmYPHtCT7w==", "dev": true, "dependencies": { "@pixi/graphics-smooth": "0.0.22", @@ -2266,12 +2266,13 @@ "dev": true }, "node_modules/5etools-utils": { - "version": "0.1.21", - "resolved": "https://registry.npmjs.org/5etools-utils/-/5etools-utils-0.1.21.tgz", - "integrity": "sha512-wOqVSRvd6h6H+SiNAFxrceZ35yyeV0LbAQ8lpSN/dv5IZ9fVqQSFMLNgM0Fa2Kl4fC9kLk8vp3XqZ2nvuw0wqA==", + "version": "0.1.23", + "resolved": "https://registry.npmjs.org/5etools-utils/-/5etools-utils-0.1.23.tgz", + "integrity": "sha512-giJndQ/Z9xYhCk69GOvPzeJyPzRYHpcM3arRD4S/uyOWMR9J7PoQpeLJc7htX/ElEF0jgYHUkkmBwa+YgHyo9g==", "dev": true, "dependencies": { "ajv": "^8.11.0", + "ajv-formats": "^2.1.1", "json-source-map": "^0.6.1" } }, @@ -2334,6 +2335,23 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dev": true, + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -3737,9 +3755,9 @@ } }, "node_modules/plutonium-utils": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/plutonium-utils/-/plutonium-utils-0.1.13.tgz", - "integrity": "sha512-pDTxhhPPmCykqvyY1gkO8fXd4gvVD8SSmUd9OSUfiCsq2eGc+mYRT19qHtz8ltO3cItH7QxlkljyiSXuwPZDAA==", + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/plutonium-utils/-/plutonium-utils-0.1.15.tgz", + "integrity": "sha512-0dISHA5Ak+YrKkC4aaDQEOPAwQrTqSwWOOidH100YaPsZjqfRATs+dQTHHjKWsWGjHRHhgQHOUKj4U1RbpCQpw==", "dev": true }, "node_modules/prelude-ls": { @@ -4346,9 +4364,9 @@ "dev": true }, "@league-of-foundry-developers/foundry-vtt-types": { - "version": "9.269.0", - "resolved": "https://registry.npmjs.org/@league-of-foundry-developers/foundry-vtt-types/-/foundry-vtt-types-9.269.0.tgz", - "integrity": "sha512-M/rz86decPLXet9e6+bi0dm8WSGrT/5MM1QXUMEC7Z8vfKB9Y5D61B1J5laaqb3DdjVDS1kZtQEW3/sPg3EALw==", + "version": "9.280.0", + "resolved": "https://registry.npmjs.org/@league-of-foundry-developers/foundry-vtt-types/-/foundry-vtt-types-9.280.0.tgz", + "integrity": "sha512-Dv8/+kgAnI2F5snSWcnMnZsgO/87AFyBruflluZkWDbP7Pm5qi32GlNYCDEg7HMKybzyKmgLV2qXMmYPHtCT7w==", "dev": true, "requires": { "@pixi/graphics-smooth": "0.0.22", @@ -6444,12 +6462,13 @@ "dev": true }, "5etools-utils": { - "version": "0.1.21", - "resolved": "https://registry.npmjs.org/5etools-utils/-/5etools-utils-0.1.21.tgz", - "integrity": "sha512-wOqVSRvd6h6H+SiNAFxrceZ35yyeV0LbAQ8lpSN/dv5IZ9fVqQSFMLNgM0Fa2Kl4fC9kLk8vp3XqZ2nvuw0wqA==", + "version": "0.1.23", + "resolved": "https://registry.npmjs.org/5etools-utils/-/5etools-utils-0.1.23.tgz", + "integrity": "sha512-giJndQ/Z9xYhCk69GOvPzeJyPzRYHpcM3arRD4S/uyOWMR9J7PoQpeLJc7htX/ElEF0jgYHUkkmBwa+YgHyo9g==", "dev": true, "requires": { "ajv": "^8.11.0", + "ajv-formats": "^2.1.1", "json-source-map": "^0.6.1" } }, @@ -6494,6 +6513,15 @@ "uri-js": "^4.2.2" } }, + "ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dev": true, + "requires": { + "ajv": "^8.0.0" + } + }, "ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -7634,9 +7662,9 @@ } }, "plutonium-utils": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/plutonium-utils/-/plutonium-utils-0.1.13.tgz", - "integrity": "sha512-pDTxhhPPmCykqvyY1gkO8fXd4gvVD8SSmUd9OSUfiCsq2eGc+mYRT19qHtz8ltO3cItH7QxlkljyiSXuwPZDAA==", + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/plutonium-utils/-/plutonium-utils-0.1.15.tgz", + "integrity": "sha512-0dISHA5Ak+YrKkC4aaDQEOPAwQrTqSwWOOidH100YaPsZjqfRATs+dQTHHjKWsWGjHRHhgQHOUKj4U1RbpCQpw==", "dev": true }, "prelude-ls": { diff --git a/package.json b/package.json index 9f724f7..ff01101 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plutonium-addon-automation", - "version": "0.1.7", + "version": "0.2.0", "author": "Giddy", "type": "module", "license": "MIT", @@ -20,14 +20,14 @@ "mt": "npm run macro-template --" }, "devDependencies": { - "@league-of-foundry-developers/foundry-vtt-types": "^9.269.0", - "5etools-utils": "^0.1.21", + "@league-of-foundry-developers/foundry-vtt-types": "^9.280.0", + "5etools-utils": "^0.1.23", "adm-zip-giddy": "^0.4.12", "ajv": "^8.10.0", "commander": "^9.1.0", "eslint": "^8.11.0", "express": "^4.17.3", "json-source-map": "^0.6.1", - "plutonium-utils": "^0.1.13" + "plutonium-utils": "^0.1.15" } } diff --git a/script/build-task.js b/script/build-task.js index ba871c0..af36609 100644 --- a/script/build-task.js +++ b/script/build-task.js @@ -19,7 +19,7 @@ export const buildTask = async () => { }, ], - name: SharedConsts.MODULE_NAME, + id: SharedConsts.MODULE_ID, title: SharedConsts.MODULE_TITLE, description: "Plutonium automations for use with Midi-QOL, DAE, and friends.", authors: [ @@ -39,68 +39,72 @@ export const buildTask = async () => { manifest: `https://github.com/TheGiddyLimit/plutonium-addon-automation/releases/latest/download/module.json`, // Set "download" to this specific version, so that users manually entering the link will receive the version they expect download: `https://github.com/TheGiddyLimit/plutonium-addon-automation/releases/download/${packageJson.version}/plutonium-addon-automation.zip`, - minimumCoreVersion: "9", - compatibleCoreVersion: "9", + compatibility: { + minimum: "10", + verified: "10.288", + }, url: "https://www.patreon.com/Giddy5e", bugs: "https://discord.gg/nGvRCDs", - dependencies: [ - { - name: "plutonium", - type: "module", - manifest: "https://raw.githubusercontent.com/TheGiddyLimit/plutonium-next/master/module.json", - }, - { - name: "midi-qol", - type: "module", - manifest: "https://gitlab.com/tposney/midi-qol/raw/master/package/module.json", - }, - { - name: "dae", - type: "module", - manifest: "https://gitlab.com/tposney/dae/raw/master/package/module.json", - }, - { - name: "times-up", - type: "module", - manifest: "https://gitlab.com/tposney/times-up/raw/master/package/module.json", - }, - { - name: "dfreds-convenient-effects", - type: "module", - manifest: "https://github.com/DFreds/dfreds-convenient-effects/releases/latest/download/module.json", - }, - ], - esmodules: [ - "./js/Main.js", - ], - flags: { - // See: - // https://foundryvtt.wiki/en/development/manifest-plus - // https://github.com/mouse0270/module-credits - "manifestPlusVersion": "1.2.0", - "conflicts": [ + + relationships: { + requires: [ { - "name": "combat-utility-belt", - "type": "module", - "description": `Redundant when used with ${SharedConsts.MODULE_TITLE} module dependencies, and often conflicts with them.`, + id: "plutonium", + type: "module", + manifest: "https://raw.githubusercontent.com/TheGiddyLimit/plutonium-next/master/module.json", }, { - "name": "betterrolls5e", - "type": "module", - "description": "May cause issues with features which require rolls; use with caution.", + id: "midi-qol", + type: "module", + manifest: "https://gitlab.com/tposney/midi-qol/raw/master/package/module.json", }, { - "name": "mars-5e", - "type": "module", - "description": "May cause issues with features which require rolls; use with caution.", + id: "dae", + type: "module", + manifest: "https://gitlab.com/tposney/dae/raw/master/package/module.json", }, { - "name": "mre-dnd5e", - "type": "module", - "description": "May cause issues with features which require rolls; use with caution.", + id: "times-up", + type: "module", + manifest: "https://gitlab.com/tposney/times-up/raw/master/package/module.json", + }, + { + id: "dfreds-convenient-effects", + type: "module", + manifest: "https://github.com/DFreds/dfreds-convenient-effects/releases/latest/download/module.json", + }, + { + id: "itemacro", + type: "module", + manifest: "https://github.com/Kekilla0/Item-Macro/releases/latest/download/module.json", + }, + ], + conflicts: [ + { + id: "combat-utility-belt", + type: "module", + reason: `Redundant when used with ${SharedConsts.MODULE_TITLE} module dependencies, and often conflicts with them.`, + }, + { + id: "betterrolls5e", + type: "module", + reason: "May cause issues with features which require rolls; use with caution.", + }, + { + id: "mars-5e", + type: "module", + reason: "May cause issues with features which require rolls; use with caution.", + }, + { + id: "mre-dnd5e", + type: "module", + reason: "May cause issues with features which require rolls; use with caution.", }, ], }, + esmodules: [ + "./js/Main.js", + ], }); const itemMacroDirs = new Set(fs.readdirSync(DIR_ITEM_MACROS)); @@ -111,7 +115,7 @@ export const buildTask = async () => { const files = Uf.listJsonFiles( path.join(SharedConsts.MODULE_DIR, "data"), { - dirBlacklist: new Set(noItemMacroDirs), + dirBlocklist: new Set(noItemMacroDirs), }, ); files diff --git a/script/package.js b/script/package.js index 4facd7e..fd01e37 100644 --- a/script/package.js +++ b/script/package.js @@ -27,9 +27,9 @@ function _zip (dirPart, zipRoot) { async function doPackage () { await buildTask(); - const zip = _zip(SharedConsts.MODULE_DIR, SharedConsts.MODULE_NAME); + const zip = _zip(SharedConsts.MODULE_DIR, SharedConsts.MODULE_ID); - const outPath = `./dist/${SharedConsts.MODULE_NAME}.zip`; + const outPath = `./dist/${SharedConsts.MODULE_ID}.zip`; zip.writeZip(outPath); console.log(`Wrote zip to: ${outPath}`); } diff --git a/test/schema/shared.json b/test/schema/shared.json index 9a511db..3e0b304 100644 --- a/test/schema/shared.json +++ b/test/schema/shared.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "shared.json", - "version": "0.4.1", + "version": "0.5.0", "definitions": { "schema": { @@ -81,7 +81,7 @@ "items": {"type": "string"} }, - "data": {"type": "object"}, + "system": {"type": "object"}, "effects": { "type": "array", @@ -115,7 +115,7 @@ "type": "object", "description": "If our \"X\" (e.g. \"data\") should be merged with any base \"X\", rather than overwriting.", "properties": { - "data": {"const": true}, + "system": {"const": true}, "effects": {"const": true}, "flags": {"const": true} } diff --git a/test/test-json.js b/test/test-json.js index 946f065..673602f 100644 --- a/test/test-json.js +++ b/test/test-json.js @@ -8,7 +8,7 @@ function main () { dirSchema: "test/schema", fnGetSchemaId: path => path.includes("__core.json") ? "core.json" : "homebrew.json", }, - ).getErrors("module/data", {dirBlacklist: new Set(["module/data/_generated"])}); + ).getErrors("module/data", {dirBlocklist: new Set(["module/data/_generated"])}); if (errors.length) { if (!process.env.CI) fs.writeFileSync(`test/test-json.error.log`, errorsFull.join("\n\n=====\n\n"));