mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
checkpoint: before migrating to nuxt v4
This commit is contained in:
@ -75,11 +75,11 @@
|
||||
<li
|
||||
v-for="gameVersion in version.gameVersions"
|
||||
:key="gameVersion.versionId"
|
||||
class="px-3 py-2 bg-zinc-800 rounded-lg shadow"
|
||||
class="px-3 py-2 border border-zinc-800 rounded-lg shadow"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
class="text-sm flex items-center text-zinc-200 font-semibold"
|
||||
class="text-sm flex items-center gap-x-2 text-zinc-200 font-semibold"
|
||||
>
|
||||
<IconsPlatform
|
||||
:platform="
|
||||
@ -91,7 +91,7 @@
|
||||
"
|
||||
class="size-5 text-blue-500"
|
||||
/>
|
||||
<span class="ml-3 block truncate">{{
|
||||
<span class="block truncate">{{
|
||||
platforms[gameVersion.platformId].name
|
||||
}}</span>
|
||||
</div>
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
"luxon": "^3.6.1",
|
||||
"micromark": "^4.0.1",
|
||||
"normalize-url": "^8.0.2",
|
||||
"nuxt": "^3.17.4",
|
||||
"nuxt": "^4.1.2",
|
||||
"nuxt-security": "2.2.0",
|
||||
"pino": "^9.7.0",
|
||||
"pino-pretty": "^13.0.0",
|
||||
|
||||
3452
pnpm-lock.yaml
generated
3452
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1 +1,4 @@
|
||||
onlyBuiltDependencies:
|
||||
- esbuild
|
||||
|
||||
shamefullyHoist: true
|
||||
|
||||
@ -13,7 +13,7 @@ import type {
|
||||
import axios, { type AxiosRequestConfig } from "axios";
|
||||
import TurndownService from "turndown";
|
||||
import { DateTime } from "luxon";
|
||||
import type { TaskRunContext } from "../tasks";
|
||||
import type { TaskRunContext } from "../tasks/utils";
|
||||
|
||||
interface GiantBombResponseType<T> {
|
||||
error: "OK" | string;
|
||||
|
||||
@ -13,8 +13,8 @@ import type { AxiosRequestConfig } from "axios";
|
||||
import axios from "axios";
|
||||
import { DateTime } from "luxon";
|
||||
import * as jdenticon from "jdenticon";
|
||||
import type { TaskRunContext } from "../tasks";
|
||||
import { logger } from "~/server/internal/logging";
|
||||
import type { TaskRunContext } from "../tasks/utils";
|
||||
|
||||
type IGDBID = number;
|
||||
|
||||
|
||||
@ -13,13 +13,14 @@ import type {
|
||||
import { ObjectTransactionalHandler } from "../objects/transactional";
|
||||
import { PriorityListIndexed } from "../utils/prioritylist";
|
||||
import { systemConfig } from "../config/sys-conf";
|
||||
import type { TaskRunContext } from "../tasks";
|
||||
import taskHandler, { wrapTaskContext } from "../tasks";
|
||||
import { randomUUID } from "crypto";
|
||||
import { fuzzy } from "fast-fuzzy";
|
||||
import { logger } from "~/server/internal/logging";
|
||||
import libraryManager, { createGameImportTaskId } from "../library";
|
||||
import type { GameTagModel } from "~/prisma/client/models";
|
||||
import type { TaskRunContext} from "../tasks/utils";
|
||||
import { wrapTaskContext } from "../tasks/utils";
|
||||
import taskHandler from "../tasks";
|
||||
|
||||
export class MissingMetadataProviderConfig extends Error {
|
||||
private providerName: string;
|
||||
|
||||
@ -15,8 +15,8 @@ import * as jdenticon from "jdenticon";
|
||||
import { DateTime } from "luxon";
|
||||
import * as cheerio from "cheerio";
|
||||
import { type } from "arktype";
|
||||
import type { TaskRunContext } from "../tasks";
|
||||
import { logger } from "~/server/internal/logging";
|
||||
import type { TaskRunContext } from "../tasks/utils";
|
||||
|
||||
interface PCGamingWikiParseRawPage {
|
||||
parse: {
|
||||
|
||||
@ -5,7 +5,7 @@ This is used as a utility in metadata handling, so we only fetch the objects if
|
||||
import type { Readable } from "stream";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import objectHandler from ".";
|
||||
import type { TaskRunContext } from "../tasks";
|
||||
import type { TaskRunContext } from "../tasks/utils";
|
||||
|
||||
export type TransactionDataType = string | Readable | Buffer;
|
||||
type TransactionTable = Map<string, TransactionDataType>; // ID to data
|
||||
|
||||
@ -13,6 +13,7 @@ import { type } from "arktype";
|
||||
import pino from "pino";
|
||||
import { logger } from "~/server/internal/logging";
|
||||
import { Writable } from "node:stream";
|
||||
import type { TaskRunContext } from "./utils";
|
||||
|
||||
// a task that has been run
|
||||
type FinishedTask = {
|
||||
@ -412,36 +413,6 @@ class TaskHandler {
|
||||
}
|
||||
}
|
||||
|
||||
export type TaskRunContext = {
|
||||
progress: (progress: number) => void;
|
||||
logger: typeof logger;
|
||||
};
|
||||
|
||||
export function wrapTaskContext(
|
||||
context: TaskRunContext,
|
||||
options: { min: number; max: number; prefix: string },
|
||||
): TaskRunContext {
|
||||
const child = context.logger.child({
|
||||
prefix: options.prefix,
|
||||
});
|
||||
|
||||
return {
|
||||
progress(progress) {
|
||||
if (progress > 100 || progress < 0) {
|
||||
logger.warn("[wrapTaskContext] progress must be between 0 and 100");
|
||||
}
|
||||
|
||||
// I was too tired to figure this out
|
||||
// https://stackoverflow.com/a/929107
|
||||
const oldRange = 100;
|
||||
const newRange = options.max - options.min;
|
||||
const adjustedProgress = (progress * newRange) / oldRange + options.min;
|
||||
return context.progress(adjustedProgress);
|
||||
},
|
||||
logger: child,
|
||||
};
|
||||
}
|
||||
|
||||
export interface Task {
|
||||
id: string;
|
||||
taskGroup: TaskGroup;
|
||||
@ -484,31 +455,6 @@ export const TaskLog = type({
|
||||
level: "string",
|
||||
});
|
||||
|
||||
// /**
|
||||
// * Create a log message with a timestamp in the format YYYY-MM-DD HH:mm:ss.SSS UTC
|
||||
// * @param message
|
||||
// * @returns
|
||||
// */
|
||||
// function msgWithTimestamp(message: string): string {
|
||||
// const now = new Date();
|
||||
|
||||
// const pad = (n: number, width = 2) => n.toString().padStart(width, "0");
|
||||
|
||||
// const year = now.getUTCFullYear();
|
||||
// const month = pad(now.getUTCMonth() + 1);
|
||||
// const day = pad(now.getUTCDate());
|
||||
|
||||
// const hours = pad(now.getUTCHours());
|
||||
// const minutes = pad(now.getUTCMinutes());
|
||||
// const seconds = pad(now.getUTCSeconds());
|
||||
// const milliseconds = pad(now.getUTCMilliseconds(), 3);
|
||||
|
||||
// const log: typeof TaskLog.infer = {
|
||||
// timestamp: `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds} UTC`,
|
||||
// message,
|
||||
// };
|
||||
// return JSON.stringify(log);
|
||||
// }
|
||||
|
||||
export function defineDropTask(buildTask: BuildTask): DropTask {
|
||||
return {
|
||||
|
||||
58
server/internal/tasks/utils.ts
Normal file
58
server/internal/tasks/utils.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { logger } from "../logging";
|
||||
|
||||
export type TaskRunContext = {
|
||||
progress: (progress: number) => void;
|
||||
logger: typeof logger;
|
||||
};
|
||||
|
||||
export function wrapTaskContext(
|
||||
context: TaskRunContext,
|
||||
options: { min: number; max: number; prefix: string },
|
||||
): TaskRunContext {
|
||||
const child = context.logger.child({
|
||||
prefix: options.prefix,
|
||||
});
|
||||
|
||||
return {
|
||||
progress(progress) {
|
||||
if (progress > 100 || progress < 0) {
|
||||
logger.warn("[wrapTaskContext] progress must be between 0 and 100");
|
||||
}
|
||||
|
||||
// I was too tired to figure this out
|
||||
// https://stackoverflow.com/a/929107
|
||||
const oldRange = 100;
|
||||
const newRange = options.max - options.min;
|
||||
const adjustedProgress = (progress * newRange) / oldRange + options.min;
|
||||
return context.progress(adjustedProgress);
|
||||
},
|
||||
logger: child,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Create a log message with a timestamp in the format YYYY-MM-DD HH:mm:ss.SSS UTC
|
||||
// * @param message
|
||||
// * @returns
|
||||
// */
|
||||
// function msgWithTimestamp(message: string): string {
|
||||
// const now = new Date();
|
||||
|
||||
// const pad = (n: number, width = 2) => n.toString().padStart(width, "0");
|
||||
|
||||
// const year = now.getUTCFullYear();
|
||||
// const month = pad(now.getUTCMonth() + 1);
|
||||
// const day = pad(now.getUTCDate());
|
||||
|
||||
// const hours = pad(now.getUTCHours());
|
||||
// const minutes = pad(now.getUTCMinutes());
|
||||
// const seconds = pad(now.getUTCSeconds());
|
||||
// const milliseconds = pad(now.getUTCMilliseconds(), 3);
|
||||
|
||||
// const log: typeof TaskLog.infer = {
|
||||
// timestamp: `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds} UTC`,
|
||||
// message,
|
||||
// };
|
||||
// return JSON.stringify(log);
|
||||
// }
|
||||
Reference in New Issue
Block a user