Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert setting Document#_stats#coreVersion in the pack builder #14600

Merged
merged 1 commit into from
May 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions build/lib/compendium-pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { RuleElementSource } from "@module/rules/index.ts";
import { isObject, recursiveReplaceString, setHasElement, sluggify, tupleHasValue } from "@util/misc.ts";
import fs from "fs";
import path from "path";
import type { JournalEntryPageSource } from "types/foundry/common/documents/journal-entry-page.ts";
import type { JournalEntrySource } from "types/foundry/common/documents/journal-entry.ts";
import coreIconsJSON from "../core-icons.json" assert { type: "json" };
import "./foundry-utils.ts";
import { getFilesRecursively, PackError } from "./helpers.ts";
Expand Down Expand Up @@ -46,16 +44,6 @@ function isItemSource(docSource: PackEntry): docSource is ItemSourcePF2e {
);
}

function isJournalSource(docSource: PackEntry): docSource is JournalEntrySource {
return "pages" in docSource && Array.isArray(docSource.pages);
}

/**
* The latest supported core schema version. This is used by the server to determine if a data migration is necessary
* and should only be increased once all new server-side migrations are supported.
*/
const SUPPORTED_CORE_SCHEMA_VERSION = "12.320";

/**
* This is used to check paths to core icons to ensure correctness. The JSON file will need to be periodically refreshed
* as upstream adds more icons.
Expand Down Expand Up @@ -259,26 +247,18 @@ class CompendiumPack {
}

docSource.flags ??= {};
this.#setSupportedCoreSchemaVersion(docSource);
if (isActorSource(docSource)) {
docSource.effects = [];
docSource.flags.core = { sourceId: this.#sourceIdOf(docSource._id ?? "", { docType: "Actor" }) };
this.#assertSizeValid(docSource);
docSource.system._migration = { version: MigrationRunnerBase.LATEST_SCHEMA_VERSION, previous: null };
for (const item of docSource.items) {
item.effects = [];
this.#setSupportedCoreSchemaVersion(item);
item.system._migration = { version: MigrationRunnerBase.LATEST_SCHEMA_VERSION, previous: null };
CompendiumPack.convertUUIDs(item, { to: "ids", map: CompendiumPack.#namesToIds.Item });
}
}

if (isJournalSource(docSource)) {
for (const page of docSource.pages) {
this.#setSupportedCoreSchemaVersion(page);
}
}

if (isItemSource(docSource)) {
docSource.effects = [];
docSource.flags.core = { sourceId: this.#sourceIdOf(docSource._id ?? "", { docType: "Item" }) };
Expand Down Expand Up @@ -322,12 +302,6 @@ class CompendiumPack {
.replace(CompendiumPack.LINK_PATTERNS.compendium, replace);
}

/** Set `_stats.coreVersion` to avoid running server-side migrations after every rebuild */
#setSupportedCoreSchemaVersion(docSource: PackEntry | JournalEntryPageSource): void {
(docSource._stats as Partial<PackEntry["_stats"]>) ??= {};
docSource._stats.coreVersion = SUPPORTED_CORE_SCHEMA_VERSION;
}

#sourceIdOf(documentId: string, { packId, docType }: { packId?: string; docType: "Actor" }): CompendiumActorUUID;
#sourceIdOf(documentId: string, { packId, docType }: { packId?: string; docType: "Item" }): CompendiumItemUUID;
#sourceIdOf(documentId: string, { packId, docType }: { packId?: string; docType: string }): string;
Expand Down
Loading