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
|
|
@ -26,7 +26,7 @@ export class PlayerData extends foundry.abstract.TypeDataModel {
|
||||||
// required: false,
|
// required: false,
|
||||||
// },
|
// },
|
||||||
// ),
|
// ),
|
||||||
attr: new fields.ObjectField({ persisted: false, }),
|
attr: new fields.ObjectField({ persisted: false }),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export async function checkMigrations() {
|
||||||
const migrationVersion = game.settings.get(__ID__, `migrationVersion`);
|
const migrationVersion = game.settings.get(__ID__, `migrationVersion`);
|
||||||
let updateVersion = !migrationVersion;
|
let updateVersion = !migrationVersion;
|
||||||
|
|
||||||
if (isNewerVersion("3.0.0", migrationVersion)) {
|
if (isNewerVersion(`3.0.0`, migrationVersion)) {
|
||||||
await migrateTo3_0_0();
|
await migrateTo3_0_0();
|
||||||
updateVersion = true;
|
updateVersion = true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export async function migrateCollection(
|
||||||
collection,
|
collection,
|
||||||
flag,
|
flag,
|
||||||
convertor,
|
convertor,
|
||||||
options = {}
|
options = {},
|
||||||
) {
|
) {
|
||||||
const toMigrate = collection
|
const toMigrate = collection
|
||||||
.filter(doc => doc.getFlag(__ID__, flag))
|
.filter(doc => doc.getFlag(__ID__, flag))
|
||||||
|
|
@ -76,11 +76,11 @@ export async function migrateCollection(
|
||||||
*/
|
*/
|
||||||
export function shouldMigrateCompendium(pack, types = [`Actor`, `Item`]) {
|
export function shouldMigrateCompendium(pack, types = [`Actor`, `Item`]) {
|
||||||
// We only care about actor and item migrations
|
// 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
|
// World compendiums should all be migrated, system ones should never by migrated
|
||||||
if (pack.metadata.packageType === "world") return true;
|
if (pack.metadata.packageType === `world`) {return true}
|
||||||
if (pack.metadata.packageType === "system") return false;
|
if (pack.metadata.packageType === `system`) {return false}
|
||||||
|
|
||||||
// Module compendiums should only be migrated if they don't have a download or manifest URL
|
// Module compendiums should only be migrated if they don't have a download or manifest URL
|
||||||
const module = game.modules.get(pack.metadata.packageName);
|
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 { __ID__ } from "../consts.mjs";
|
||||||
import { Logger } from "../utils/Logger.mjs";
|
import { Logger } from "../utils/Logger.mjs";
|
||||||
import { finishMigrationWarning, migrateCollection, shouldMigrateCompendium } from "./utils.mjs";
|
|
||||||
|
|
||||||
const flag = `convertAttributesIntoItems`;
|
const flag = `convertAttributesIntoItems`;
|
||||||
const worldOperations = [];
|
const worldOperations = [];
|
||||||
|
|
@ -13,7 +17,7 @@ export async function migrateTo3_0_0() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const warning = ui.notifications.warn(
|
const warning = ui.notifications.warn(
|
||||||
"taf.notifs.warn.migration-in-progress",
|
`taf.notifs.warn.migration-in-progress`,
|
||||||
{
|
{
|
||||||
localize: true,
|
localize: true,
|
||||||
format: { version: `3.0.0` },
|
format: { version: `3.0.0` },
|
||||||
|
|
@ -27,29 +31,29 @@ export async function migrateTo3_0_0() {
|
||||||
game.actors,
|
game.actors,
|
||||||
flag,
|
flag,
|
||||||
handleMigratingActor,
|
handleMigratingActor,
|
||||||
{ update: false, },
|
{ update: false },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
warning.update({ pct: 0.25, });
|
warning.update({ pct: 0.25 });
|
||||||
|
|
||||||
for (const pack of packsToMigrate) {
|
for (const pack of packsToMigrate) {
|
||||||
await pack.getDocuments();
|
await pack.getDocuments();
|
||||||
|
|
||||||
const wasLocked = pack.config.locked;
|
const wasLocked = pack.config.locked;
|
||||||
if (wasLocked) await pack.configure({ locked: false });
|
if (wasLocked) {await pack.configure({ locked: false })}
|
||||||
|
|
||||||
compendiumOperations.push(
|
compendiumOperations.push(
|
||||||
...await migrateCollection(
|
...await migrateCollection(
|
||||||
pack,
|
pack,
|
||||||
flag,
|
flag,
|
||||||
handleMigratingActor,
|
handleMigratingActor,
|
||||||
{ pack: pack.collection, update: false, },
|
{ pack: pack.collection, update: false },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await foundry.documents.modifyBatch(compendiumOperations);
|
await foundry.documents.modifyBatch(compendiumOperations);
|
||||||
|
|
||||||
if (wasLocked) await pack.configure({ locked: true });
|
if (wasLocked) {await pack.configure({ locked: true })}
|
||||||
|
|
||||||
compendiumOperations = [];
|
compendiumOperations = [];
|
||||||
};
|
};
|
||||||
|
|
@ -94,7 +98,7 @@ function handleMigratingActor(actor, options) {
|
||||||
function convertToItem(key, attr) {
|
function convertToItem(key, attr) {
|
||||||
return {
|
return {
|
||||||
name: attr.name,
|
name: attr.name,
|
||||||
type: "attribute",
|
type: `attribute`,
|
||||||
system: {
|
system: {
|
||||||
key,
|
key,
|
||||||
value: attr.value,
|
value: attr.value,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue