Merge branch 'explosivegaming:main' into aperx

This commit is contained in:
phidias authored and GitHub committed 2026-10-29 15:32:20 +09:00
commit 99f17a83ce
69 files changed
+218 -571

No files matched your search

+6 -8
View File
@@ -95,12 +95,10 @@ export class ControllerPlugin {
const controller = context.controller;
const databaseDirectory = controller.config.get("controller.database_directory");
const accounts = new lib.SubscribableDatastore(
...await new lib.JsonIdDatastoreProvider(
path.join(databaseDirectory, "exp_discord_auth", "accounts.json"),
messages.DiscordAccountRecord.fromJSON.bind(messages.DiscordAccountRecord),
).bootstrap()
);
const accounts = await lib.SubscribableDatastore.fromProvider(new lib.JsonIdDatastoreProvider(
path.join(databaseDirectory, "exp_discord_auth", "accounts.json"),
messages.DiscordAccountRecord.fromJSON.bind(messages.DiscordAccountRecord),
));
return new ControllerPlugin(controller, context.logger, context.plugin.name, accounts);
}
@@ -387,7 +385,7 @@ export class ControllerPlugin {
const entry = this.codes.get(code);
const session = entry ? this.sessions.get(entry.sessionId) : undefined;
if (!entry || !session || entry.expiresMs < Date.now()) {
throw new lib.RequestError(
throw new lib.ValidationError(
`This code is invalid or has expired, get a new one from ${this.controller.getControllerUrl()}`
);
}
@@ -405,7 +403,7 @@ export class ControllerPlugin {
const alreadyLinked = existing?.factorioNames.some(linked => linked.toLowerCase() === name);
const maxAccounts = this.controller.config.get("exp_discord_auth.max_accounts");
if (!alreadyLinked && (existing?.factorioNames.length ?? 0) >= maxAccounts) {
throw new lib.RequestError(
throw new lib.ConflictError(
`${discordUser.name} already has ${maxAccounts} Factorio accounts linked, unlink one first`
);
}
+3 -5
View File
@@ -8,7 +8,7 @@
"type": "module",
"main": "dist/node/index.js",
"scripts": {
"prepare": "tsc --build && webpack-cli --env production",
"prepare": "tsc --build && vite build",
"test": "tap --type-strip-only --disable-coverage --allow-empty-coverage test/*.test.js",
"coverage": "tap --coverage-report=text test/*.test.js"
},
@@ -40,11 +40,9 @@
"react": "catalog:",
"react-dom": "catalog:",
"react-router-dom": "catalog:",
"typescript": "catalog:",
"webpack": "catalog:",
"tap": "^21.1.0",
"webpack-cli": "catalog:",
"webpack-merge": "catalog:"
"typescript": "catalog:",
"vite": "catalog:"
},
"dependencies": {
"@sinclair/typebox": "catalog:",
+6
View File
@@ -0,0 +1,6 @@
import { defineConfig } from "vite";
import { clusterioPlugin } from "@clusterio/web_ui/vite.mjs";
export default defineConfig({
plugins: [clusterioPlugin()],
});
-34
View File
@@ -1,34 +0,0 @@
"use strict";
const path = require("path");
const webpack = require("webpack");
const { merge } = require("webpack-merge");
const common = require("@clusterio/web_ui/webpack.common");
module.exports = (env = {}) => merge(common(env), {
context: __dirname,
entry: "./web/index.tsx",
output: {
path: path.resolve(__dirname, "dist", "web"),
},
plugins: [
new webpack.container.ModuleFederationPlugin({
name: "exp_discord_auth",
library: { type: "window", name: "plugin_exp_discord_auth" },
exposes: {
"./": "./index.ts",
"./package.json": "./package.json",
"./web": "./web/index.tsx",
},
shared: {
"@clusterio/lib": { import: false },
"@clusterio/web_ui": { import: false },
"antd": { import: false },
"react": { import: false },
"react-dom": { import: false },
"react-router": { import: false },
"react-router-dom": { import: false },
},
}),
],
});