Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion components/GameEditor/Metadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
accept="image/*"
class="hidden"
type="file"
@change="(e) => coreMetadataUploadFiles(e as any)"
@change="(e: Event) => coreMetadataUploadFiles(e as any)"
/>
</label>
</div>
Expand Down
4 changes: 3 additions & 1 deletion components/GamePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
:class="{ 'group-hover:text-white transition-colors': animate }"
class="text-zinc-100 text-sm font-bold font-display"
>
{{ game ? game.mName : $t("settings.admin.store.dropGameNamePlaceholder") }}
{{
game ? game.mName : $t("settings.admin.store.dropGameNamePlaceholder")
}}
</h1>
<p
:class="{
Expand Down
2 changes: 1 addition & 1 deletion components/NewsArticleCreateButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
accept="image/*"
class="hidden"
type="file"
@change="(e) => (file = (e.target as any)?.files)"
@change="(e: Event) => (file = (e.target as any)?.files)"
/>
</div>

Expand Down
8 changes: 4 additions & 4 deletions components/OptionWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
]"
>
<div v-if="active" class="absolute top-1 right-1 z-1">
<CheckIcon
class="rounded-full p-1.5 bg-blue-600 size-6 text-transparent stroke-3 stroke-zinc-900 font-bold"
/>
<CheckIcon
class="rounded-full p-1.5 bg-blue-600 size-6 text-transparent stroke-3 stroke-zinc-900 font-bold"
/>
</div>

<slot />
</div>
</template>

<script setup lang="ts">
import { CheckIcon } from '@heroicons/vue/24/solid';
import { CheckIcon } from "@heroicons/vue/24/solid";

const { active = false } = defineProps<{ active?: boolean }>();
</script>
2 changes: 1 addition & 1 deletion components/UploadFileDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
class="hidden"
type="file"
:multiple="props.multiple"
@change="(e) => (file = (e.target as any)?.files)"
@change="(e: Event) => (file = (e.target as any)?.files)"
/>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions composables/task.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { TaskMessage } from "~/server/internal/tasks";
import { WebSocketHandler } from "./ws";
import { logger } from "~/server/internal/logging";

const websocketHandler = new WebSocketHandler("/api/v1/task");
// const taskStates: { [key: string]: } = {};
Expand Down Expand Up @@ -38,7 +39,7 @@ websocketHandler.listen((message) => {
case "disconnect": {
const disconnectTaskId = data[0];
taskStates.delete(disconnectTaskId);
console.log(`disconnected from ${disconnectTaskId}`);
logger.info(`disconnected from ${disconnectTaskId}`);
break;
}
case "error": {
Expand Down Expand Up @@ -71,7 +72,7 @@ export const useTask = (taskId: string): Ref<TaskMessage | undefined> => {
if (task && task.value && !task.value.error) return task;

taskStates.set(taskId, ref(undefined));
console.log("connecting to " + taskId);
logger.info("connecting to " + taskId);
websocketHandler.send(`connect/${taskId}`);
// TODO: this may have changed behavior
return taskStates.get(taskId) ?? ref(undefined);
Expand Down
65 changes: 54 additions & 11 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import tailwindcss from "@tailwindcss/vite";
import { execSync } from "node:child_process";
import { cpSync } from "node:fs";
import { cpSync, readFileSync, existsSync } from "node:fs";
import path from "node:path";
import module from "module";
import { viteStaticCopy } from "vite-plugin-static-copy";
import { type } from "arktype";

// get drop version
const dropVersion = process.env.BUILD_DROP_VERSION ?? "v0.3.0-alpha.1";
// example nightly: "v0.3.0-nightly.2025.05.28"

// get git ref or supply during build
const commitHash =
process.env.BUILD_GIT_REF ??
execSync("git rev-parse --short HEAD").toString().trim();

console.log(`Building Drop ${dropVersion} #${commitHash}`);
const packageJsonSchema = type({
name: "string",
version: "string",
});

const twemojiJson = module.findPackageJSON(
"@discordapp/twemoji",
Expand All @@ -24,6 +19,16 @@ if (!twemojiJson) {
throw new Error("Could not find @discordapp/twemoji package.");
}

// get drop version
const dropVersion = getDropVersion();

// get git ref or supply during build
const commitHash =
process.env.BUILD_GIT_REF ??
execSync("git rev-parse --short HEAD").toString().trim();

console.log(`Drop ${dropVersion} #${commitHash}`);

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
extends: ["./drop-base"],
Expand Down Expand Up @@ -257,3 +262,41 @@ export default defineNuxtConfig({
requestSizeLimiter: false,
},
});

/**
* Gets the drop version from the environment variable or package.json
* @returns {string} The drop version
*/
function getDropVersion(): string {
// get drop version from environment variable
if (process.env.BUILD_DROP_VERSION) {
return process.env.BUILD_DROP_VERSION;
}
// example nightly: "v0.3.0-nightly.2025.05.28"
const defaultVersion = "v0.0.0-alpha.0";

// get path
const packageJsonPath = path.join(
path.dirname(import.meta.url.replace("file://", "")),
"package.json",
);
console.log(`Reading package.json from ${packageJsonPath}`);
if (!existsSync(packageJsonPath)) {
console.error("Could not find package.json, using default version.");
return defaultVersion;
}

// parse package.json
const raw = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
const packageJson = packageJsonSchema(raw);
if (packageJson instanceof type.errors) {
console.error("Failed to parse package.json", packageJson.summary);
return defaultVersion;
}

// ensure version starts with 'v'
if (packageJson.version.startsWith("v")) {
return packageJson.version;
}
return `v${packageJson.version}`;
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drop",
"version": "0.3.0",
"version": "0.3.0-alpha.0",
"private": true,
"type": "module",
"license": "AGPL-3.0-or-later",
Expand Down Expand Up @@ -41,6 +41,8 @@
"normalize-url": "^8.0.2",
"nuxt": "^3.17.4",
"nuxt-security": "2.2.0",
"pino": "^9.7.0",
"pino-pretty": "^13.0.0",
"prisma": "^6.7.0",
"sanitize-filename": "^1.6.3",
"semver": "^7.7.1",
Expand Down
4 changes: 3 additions & 1 deletion plugins/error-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { logger } from "~/server/internal/logging";

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook("vue:error", (error, instance, info) => {
console.error(error, instance, info);
logger.error(info, error, instance);
});
});
3 changes: 2 additions & 1 deletion server/api/v1/auth/signin/simple.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import authManager, {
checkHashArgon2,
checkHashBcrypt,
} from "~/server/internal/auth";
import { logger } from "~/server/internal/logging";

const signinValidator = type({
username: "string",
Expand All @@ -28,7 +29,7 @@ export default defineEventHandler<{
const body = signinValidator(await readBody(h3));
if (body instanceof type.errors) {
// hover out.summary to see validation errors
console.error(body.summary);
logger.error(body.summary);

throw createError({
statusCode: 400,
Expand Down
3 changes: 2 additions & 1 deletion server/api/v1/notifications/ws.get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import notificationSystem from "~/server/internal/notifications";
import aclManager from "~/server/internal/acls";
import { logger } from "~/server/internal/logging";

// TODO add web socket sessions for horizontal scaling
// Peer ID to user ID
Expand Down Expand Up @@ -29,7 +30,7 @@ export default defineWebSocketHandler({
async close(peer, _details) {
const userId = socketSessions.get(peer.id);
if (!userId) {
console.log(`skipping websocket close for ${peer.id}`);
logger.info(`skipping websocket close for ${peer.id}`);
return;
}

Expand Down
3 changes: 0 additions & 3 deletions server/internal/acls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ class ACLManager {
if (tokenACLIndex != -1) return token.userId;
}

console.log(token);
console.log(acls);

return undefined;
}

Expand Down
7 changes: 4 additions & 3 deletions server/internal/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AuthMec } from "~/prisma/client";
import { OIDCManager } from "./oidc";
import { logger } from "~/server/internal/logging";

class AuthManager {
private authProviders: {
Expand All @@ -21,7 +22,7 @@ class AuthManager {
};

constructor() {
console.log("AuthManager initialized");
logger.info("AuthManager initialized");
}

async init() {
Expand All @@ -31,9 +32,9 @@ class AuthManager {
if (!object) break;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this.authProviders as any)[key] = object;
console.log(`enabled auth: ${key}`);
logger.info(`enabled auth: ${key}`);
} catch (e) {
console.warn(e);
logger.warn(e);
}
}

Expand Down
3 changes: 2 additions & 1 deletion server/internal/auth/oidc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import objectHandler from "../../objects";
import type { Readable } from "stream";
import * as jdenticon from "jdenticon";
import { systemConfig } from "../../config/sys-conf";
import { logger } from "~/server/internal/logging";

interface OIDCWellKnown {
authorization_endpoint: string;
Expand Down Expand Up @@ -206,7 +207,7 @@ export class OIDCManager {

return { user, options: session.options };
} catch (e) {
console.error(e);
logger.error(e);
return `Request to identity provider failed: ${e}`;
}
}
Expand Down
8 changes: 4 additions & 4 deletions server/internal/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class LibraryManager {
taskGroup: "import:game",
name: `Importing version ${versionName} for ${game.mName}`,
acls: ["system:import:version:read"],
async run({ progress, log }) {
async run({ progress, logger }) {
// First, create the manifest via droplet.
// This takes up 90% of our progress, so we wrap it in a *0.9
const manifest = await library.generateDropletManifest(
Expand All @@ -235,11 +235,11 @@ class LibraryManager {
},
(err, value) => {
if (err) throw err;
log(value);
logger.info(value);
},
);

log("Created manifest successfully!");
logger.info("Created manifest successfully!");

const currentIndex = await prisma.gameVersion.count({
where: { gameId: gameId },
Expand Down Expand Up @@ -282,7 +282,7 @@ class LibraryManager {
});
}

log("Successfully created version!");
logger.info("Successfully created version!");

notificationSystem.systemPush({
nonce: `version-create-${gameId}-${versionName}`,
Expand Down
12 changes: 12 additions & 0 deletions server/internal/logging/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pino from "pino";

export const logger = pino({
transport: {
target: "pino-pretty",
options: {
colorize: true,
},
},
});

logger.child({});
Loading