Johannes Loher
da1f6999eb
World data (including compendium packs) is migrated automatically. In order to also migrate packs provided by modules, you can use the following macro: ```js const pack = game.packs.get("<name-of-the-module>.<name-of-the-pack>"); game.ds4.migration.migrateCompendiumFromTo(pack, 4, 5); ```
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import {
|
|
getActorUpdateDataGetter,
|
|
getCompendiumMigrator,
|
|
getSceneUpdateDataGetter,
|
|
migrateActors,
|
|
migrateCompendiums,
|
|
migrateItems,
|
|
migrateScenes,
|
|
} from "./migrationHelpers";
|
|
|
|
async function migrate(): Promise<void> {
|
|
await migrateItems(getItemUpdateData);
|
|
await migrateActors(getActorUpdateData);
|
|
await migrateScenes(getSceneUpdateData);
|
|
await migrateCompendiums(migrateCompendium);
|
|
}
|
|
|
|
function getItemUpdateData(itemData: Partial<foundry.data.ItemData["_source"]>) {
|
|
if (!["loot"].includes(itemData.type ?? "")) return undefined;
|
|
return {
|
|
data: {
|
|
"-=equipped": null,
|
|
},
|
|
};
|
|
}
|
|
|
|
const getActorUpdateData = getActorUpdateDataGetter(getItemUpdateData);
|
|
const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData);
|
|
const migrateCompendium = getCompendiumMigrator(
|
|
{ getItemUpdateData, getActorUpdateData },
|
|
{ migrateToTemplateEarly: false },
|
|
);
|
|
|
|
export const migration = {
|
|
migrate,
|
|
migrateCompendium,
|
|
};
|