mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-15 17:21:13 +10:00
Rearchitecture for v0.4.0 (#197)
* feat: database redist support * feat: rearchitecture of database schemas, migration reset, and #180 * feat: import redists * fix: giantbomb logging bug * feat: partial user platform support + statusMessage -> message * feat: add user platform filters to store view * fix: sanitize svg uploads ... copilot suggested this I feel dirty. * feat: beginnings of platform & redist management * feat: add server side redist patching * fix: update drop-base commit * feat: import of custom platforms & file extensions * fix: redelete platform * fix: remove platform * feat: uninstall commands, new R UI * checkpoint: before migrating to nuxt v4 * update to nuxt 4 * fix: fixes for Nuxt v4 update * fix: remaining type issues * feat: initial feedback to import other kinds of versions * working commit * fix: lint * feat: redist import
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
import type { GameVersionModel } from "~/prisma/client/models";
|
||||
import prisma from "../db/database";
|
||||
import { sum } from "~/utils/array";
|
||||
|
||||
@ -15,11 +14,11 @@ export type DropManifest = {
|
||||
|
||||
export type DropManifestMetadata = {
|
||||
manifest: DropManifest;
|
||||
versionName: string;
|
||||
versionId: string;
|
||||
};
|
||||
|
||||
export type DropGeneratedManifest = DropManifest & {
|
||||
[key: string]: { versionName: string };
|
||||
[key: string]: { versionId: string };
|
||||
};
|
||||
|
||||
class ManifestGenerator {
|
||||
@ -32,7 +31,7 @@ class ManifestGenerator {
|
||||
Object.entries(rootManifest.manifest).map(([key, value]) => {
|
||||
return [
|
||||
key,
|
||||
Object.assign({}, value, { versionName: rootManifest.versionName }),
|
||||
Object.assign({}, value, { versionId: rootManifest.versionId }),
|
||||
];
|
||||
}),
|
||||
);
|
||||
@ -45,7 +44,7 @@ class ManifestGenerator {
|
||||
for (const [filename, chunk] of Object.entries(version.manifest)) {
|
||||
if (manifest[filename]) continue;
|
||||
manifest[filename] = Object.assign({}, chunk, {
|
||||
versionName: version.versionName,
|
||||
versionId: version.versionId,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -54,14 +53,26 @@ class ManifestGenerator {
|
||||
}
|
||||
|
||||
// Local function because eventual caching
|
||||
async generateManifest(gameId: string, versionName: string) {
|
||||
const versions: GameVersionModel[] = [];
|
||||
async generateManifest(versionId: string) {
|
||||
const versions = [];
|
||||
|
||||
const baseVersion = await prisma.gameVersion.findUnique({
|
||||
where: {
|
||||
gameId_versionName: {
|
||||
gameId: gameId,
|
||||
versionName: versionName,
|
||||
versionId,
|
||||
version: {
|
||||
gameId: {
|
||||
not: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
platform: true,
|
||||
version: {
|
||||
select: {
|
||||
gameId: true,
|
||||
dropletManifest: true,
|
||||
versionIndex: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -73,31 +84,42 @@ class ManifestGenerator {
|
||||
// Start at the same index minus one, and keep grabbing them
|
||||
// until we run out or we hit something that isn't a delta
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
for (let i = baseVersion.versionIndex - 1; true; i--) {
|
||||
for (let i = baseVersion.version.versionIndex - 1; true; i--) {
|
||||
const currentVersion = await prisma.gameVersion.findFirst({
|
||||
where: {
|
||||
gameId: gameId,
|
||||
versionIndex: i,
|
||||
platform: baseVersion.platform,
|
||||
version: {
|
||||
gameId: baseVersion.version.gameId!,
|
||||
versionIndex: i,
|
||||
},
|
||||
platform: {
|
||||
id: baseVersion.platform.id,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
version: {
|
||||
select: {
|
||||
dropletManifest: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!currentVersion) return undefined;
|
||||
versions.push(currentVersion);
|
||||
if (!currentVersion.delta) break;
|
||||
if (!currentVersion?.delta) break;
|
||||
}
|
||||
}
|
||||
const leastToMost = versions.reverse();
|
||||
const metadata: DropManifestMetadata[] = leastToMost.map((e) => {
|
||||
versions.reverse();
|
||||
const metadata: DropManifestMetadata[] = versions.map((gameVersion) => {
|
||||
return {
|
||||
manifest: JSON.parse(
|
||||
e.dropletManifest?.toString() ?? "{}",
|
||||
gameVersion.version.dropletManifest?.toString() ?? "{}",
|
||||
) as DropManifest,
|
||||
versionName: e.versionName,
|
||||
versionId: gameVersion.versionId,
|
||||
};
|
||||
});
|
||||
|
||||
const manifest = ManifestGenerator.generateManifestFromMetadata(
|
||||
metadata[0],
|
||||
metadata[0]!,
|
||||
...metadata.slice(1),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user