Lint the code that I fairly copy-pasted from draw-steel
This commit is contained in:
parent
3fff439483
commit
6461057647
4 changed files with 18 additions and 14 deletions
|
|
@ -13,7 +13,7 @@ export async function checkMigrations() {
|
|||
const migrationVersion = game.settings.get(__ID__, `migrationVersion`);
|
||||
let updateVersion = !migrationVersion;
|
||||
|
||||
if (isNewerVersion("3.0.0", migrationVersion)) {
|
||||
if (isNewerVersion(`3.0.0`, migrationVersion)) {
|
||||
await migrateTo3_0_0();
|
||||
updateVersion = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export async function migrateCollection(
|
|||
collection,
|
||||
flag,
|
||||
convertor,
|
||||
options = {}
|
||||
options = {},
|
||||
) {
|
||||
const toMigrate = collection
|
||||
.filter(doc => doc.getFlag(__ID__, flag))
|
||||
|
|
@ -76,11 +76,11 @@ export async function migrateCollection(
|
|||
*/
|
||||
export function shouldMigrateCompendium(pack, types = [`Actor`, `Item`]) {
|
||||
// We only care about actor and item migrations
|
||||
if (!types.includes(pack.documentName)) return false;
|
||||
if (!types.includes(pack.documentName)) {return false}
|
||||
|
||||
// World compendiums should all be migrated, system ones should never by migrated
|
||||
if (pack.metadata.packageType === "world") return true;
|
||||
if (pack.metadata.packageType === "system") return false;
|
||||
if (pack.metadata.packageType === `world`) {return true}
|
||||
if (pack.metadata.packageType === `system`) {return false}
|
||||
|
||||
// Module compendiums should only be migrated if they don't have a download or manifest URL
|
||||
const module = game.modules.get(pack.metadata.packageName);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import {
|
||||
finishMigrationWarning,
|
||||
migrateCollection,
|
||||
shouldMigrateCompendium,
|
||||
} from "./utils.mjs";
|
||||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { finishMigrationWarning, migrateCollection, shouldMigrateCompendium } from "./utils.mjs";
|
||||
|
||||
const flag = `convertAttributesIntoItems`;
|
||||
const worldOperations = [];
|
||||
|
|
@ -13,7 +17,7 @@ export async function migrateTo3_0_0() {
|
|||
);
|
||||
|
||||
const warning = ui.notifications.warn(
|
||||
"taf.notifs.warn.migration-in-progress",
|
||||
`taf.notifs.warn.migration-in-progress`,
|
||||
{
|
||||
localize: true,
|
||||
format: { version: `3.0.0` },
|
||||
|
|
@ -27,29 +31,29 @@ export async function migrateTo3_0_0() {
|
|||
game.actors,
|
||||
flag,
|
||||
handleMigratingActor,
|
||||
{ update: false, },
|
||||
{ update: false },
|
||||
),
|
||||
);
|
||||
warning.update({ pct: 0.25, });
|
||||
warning.update({ pct: 0.25 });
|
||||
|
||||
for (const pack of packsToMigrate) {
|
||||
await pack.getDocuments();
|
||||
|
||||
const wasLocked = pack.config.locked;
|
||||
if (wasLocked) await pack.configure({ locked: false });
|
||||
if (wasLocked) {await pack.configure({ locked: false })}
|
||||
|
||||
compendiumOperations.push(
|
||||
...await migrateCollection(
|
||||
pack,
|
||||
flag,
|
||||
handleMigratingActor,
|
||||
{ pack: pack.collection, update: false, },
|
||||
{ pack: pack.collection, update: false },
|
||||
),
|
||||
);
|
||||
|
||||
await foundry.documents.modifyBatch(compendiumOperations);
|
||||
|
||||
if (wasLocked) await pack.configure({ locked: true });
|
||||
if (wasLocked) {await pack.configure({ locked: true })}
|
||||
|
||||
compendiumOperations = [];
|
||||
};
|
||||
|
|
@ -94,7 +98,7 @@ function handleMigratingActor(actor, options) {
|
|||
function convertToItem(key, attr) {
|
||||
return {
|
||||
name: attr.name,
|
||||
type: "attribute",
|
||||
type: `attribute`,
|
||||
system: {
|
||||
key,
|
||||
value: attr.value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue