mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
Merge branch 'explosivegaming:main' into aperx
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
name: Node.js CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
# The packages use workspace:^ and catalog: versions, so they only resolve
|
||||||
|
# inside a clusterio checkout with this repository under external_plugins
|
||||||
|
CLUSTERIO_REPOSITORY: clusterio/clusterio
|
||||||
|
CLUSTERIO_REF: master
|
||||||
|
# Node version to use for the tests. This is used by the setup-node action
|
||||||
|
NODE_VERSION: lts/*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: external_plugins/ExpCluster
|
||||||
|
steps:
|
||||||
|
- name: Checkout Clusterio
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: ${{ env.CLUSTERIO_REPOSITORY }}
|
||||||
|
ref: ${{ env.CLUSTERIO_REF }}
|
||||||
|
- name: Checkout ExpCluster
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: external_plugins/ExpCluster
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
- name: Install and build
|
||||||
|
working-directory: .
|
||||||
|
run: pnpm install --no-frozen-lockfile
|
||||||
|
- name: Run tests
|
||||||
|
run: pnpm --filter "@expcluster/*" run test
|
||||||
|
- name: Run reference checks
|
||||||
|
run: |
|
||||||
|
# pnpm install runs prepare in dependency order, which hides missing
|
||||||
|
# project references. Building from an empty dist one package at a time
|
||||||
|
# will fail unless every cross package import is referenced correctly.
|
||||||
|
for pkg in exp_*/; do
|
||||||
|
rm -rf exp_*/dist
|
||||||
|
echo "::group::${pkg%/}"
|
||||||
|
(cd "$pkg" && pnpm exec tsc --build)
|
||||||
|
echo "::endgroup::"
|
||||||
|
done
|
||||||
+1
-1
@@ -9,7 +9,7 @@ For developers wanting to add features please follow these guidelines:
|
|||||||
- Lua is checked with [emmylua](https://github.com/EmmyLuaLs/emmylua-analyzer-rust), configured by `.emmyrc.json`. Install the EmmyLua extension rather than sumnekolua / luals, and use factoriomod-debug to generate the factorio api types. Note that an inline cast must be written `--[[@as T]]`, the spaced form is not parsed.
|
- Lua is checked with [emmylua](https://github.com/EmmyLuaLs/emmylua-analyzer-rust), configured by `.emmyrc.json`. Install the EmmyLua extension rather than sumnekolua / luals, and use factoriomod-debug to generate the factorio api types. Note that an inline cast must be written `--[[@as T]]`, the spaced form is not parsed.
|
||||||
- Changes should be made on your own fork and merged into `main` through a pull request.
|
- Changes should be made on your own fork and merged into `main` through a pull request.
|
||||||
- Each pull request should be limited to one feature or a few bug fixes and link to the related issue page.
|
- Each pull request should be limited to one feature or a few bug fixes and link to the related issue page.
|
||||||
- Pull requests are automatically linted and documentation checked.
|
- Pull requests are automatically linted, then built and tested against the latest clusterio `master`.
|
||||||
- Pull requests are manually reviewed to maintain code and language quality.
|
- Pull requests are manually reviewed to maintain code and language quality.
|
||||||
- New features should have the branch names: `feature/feature-name`
|
- New features should have the branch names: `feature/feature-name`
|
||||||
- Bug fixes should have the branch names: `fix/bug-name`
|
- Bug fixes should have the branch names: `fix/bug-name`
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
name: "exp_commands",
|
name: "exp_commands",
|
||||||
title: "exp_commands",
|
title: "exp_commands",
|
||||||
description: "Example Description. Plugin. Change me in index.ts",
|
description: "Example Description. Plugin. Change me in index.ts",
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production"
|
"prepare": "tsc --build && webpack-cli --env production"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BaseControllerPlugin } from "@clusterio/controller";
|
import { BaseControllerPlugin } from "@clusterio/controller";
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
import * as path from "node:path";
|
import * as path from "node:path";
|
||||||
|
|
||||||
export class ControllerPlugin extends BaseControllerPlugin {
|
export class ControllerPlugin extends BaseControllerPlugin {
|
||||||
|
|||||||
+124
-122
@@ -1,8 +1,8 @@
|
|||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
|
|
||||||
export * from "./messages";
|
export * from "./messages.js";
|
||||||
export type { ControllerPlugin } from "./controller";
|
export type { ControllerPlugin } from "./controller.js";
|
||||||
|
|
||||||
declare module "@clusterio/lib" {
|
declare module "@clusterio/lib" {
|
||||||
export interface InstanceConfigFields {
|
export interface InstanceConfigFields {
|
||||||
@@ -12,123 +12,6 @@ declare module "@clusterio/lib" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group permissions
|
|
||||||
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.group.get",
|
|
||||||
title: "Get Groups",
|
|
||||||
description: "Retrieve a specific Factorio permission group by ID.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.group.list",
|
|
||||||
title: "List Groups",
|
|
||||||
description: "List all Factorio permission groups.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.group.subscribe",
|
|
||||||
title: "Subscribe to Group Updates",
|
|
||||||
description: "Receive updates when Factorio permission groups change.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.group.create",
|
|
||||||
title: "Create Groups",
|
|
||||||
description: "Create new Factorio permission groups.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.group.update",
|
|
||||||
title: "Update Groups",
|
|
||||||
description: "Modify existing Factorio permission groups.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.group.delete",
|
|
||||||
title: "Delete Groups",
|
|
||||||
description: "Delete Factorio permission groups.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assignment permissions
|
|
||||||
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.assignment.get",
|
|
||||||
title: "Get Assignments",
|
|
||||||
description: "Retrieve a specific manual group assignment for a player.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.assignment.list",
|
|
||||||
title: "List Assignments",
|
|
||||||
description: "List all manual group assignments.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.assignment.subscribe",
|
|
||||||
title: "Subscribe to Assignment Updates",
|
|
||||||
description: "Receive updates when manual group assignments change.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.assignment.create",
|
|
||||||
title: "Create Assignments",
|
|
||||||
description: "Manually assign players to groups, overriding role mappings.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.assignment.update",
|
|
||||||
title: "Update Assignments",
|
|
||||||
description: "Modify existing manual group assignments.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.assignment.delete",
|
|
||||||
title: "Delete Assignments",
|
|
||||||
description: "Remove manual group assignments.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Role mapping permissions
|
|
||||||
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.role_mapping.get",
|
|
||||||
title: "Get Role Mappings",
|
|
||||||
description: "Retrieve a specific role mapping rule.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.role_mapping.list",
|
|
||||||
title: "List Role Mappings",
|
|
||||||
description: "List all role mapping rules.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.role_mapping.subscribe",
|
|
||||||
title: "Subscribe to Role Mapping Updates",
|
|
||||||
description: "Receive updates when role mapping rules change.",
|
|
||||||
grantByDefault: true,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.role_mapping.create",
|
|
||||||
title: "Create Role Mappings",
|
|
||||||
description: "Create rules that map user roles to Factorio permission groups.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.role_mapping.update",
|
|
||||||
title: "Update Role Mappings",
|
|
||||||
description: "Modify existing role mapping rules.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_groups.role_mapping.delete",
|
|
||||||
title: "Delete Role Mappings",
|
|
||||||
description: "Delete role mapping rules.",
|
|
||||||
grantByDefault: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const plugin: lib.PluginDeclaration = {
|
export const plugin: lib.PluginDeclaration = {
|
||||||
name: "exp_groups",
|
name: "exp_groups",
|
||||||
title: "ExpGaming - Permission Groups",
|
title: "ExpGaming - Permission Groups",
|
||||||
@@ -164,7 +47,126 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
messages.RoleMappingListRequest,
|
messages.RoleMappingListRequest,
|
||||||
],
|
],
|
||||||
|
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
permissions: [
|
||||||
|
// Group permissions
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "exp_groups.group.get",
|
||||||
|
title: "Get Groups",
|
||||||
|
description: "Retrieve a specific Factorio permission group by ID.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.group.list",
|
||||||
|
title: "List Groups",
|
||||||
|
description: "List all Factorio permission groups.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.group.subscribe",
|
||||||
|
title: "Subscribe to Group Updates",
|
||||||
|
description: "Receive updates when Factorio permission groups change.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.group.create",
|
||||||
|
title: "Create Groups",
|
||||||
|
description: "Create new Factorio permission groups.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.group.update",
|
||||||
|
title: "Update Groups",
|
||||||
|
description: "Modify existing Factorio permission groups.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.group.delete",
|
||||||
|
title: "Delete Groups",
|
||||||
|
description: "Delete Factorio permission groups.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Assignment permissions
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "exp_groups.assignment.get",
|
||||||
|
title: "Get Assignments",
|
||||||
|
description: "Retrieve a specific manual group assignment for a player.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.assignment.list",
|
||||||
|
title: "List Assignments",
|
||||||
|
description: "List all manual group assignments.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.assignment.subscribe",
|
||||||
|
title: "Subscribe to Assignment Updates",
|
||||||
|
description: "Receive updates when manual group assignments change.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.assignment.create",
|
||||||
|
title: "Create Assignments",
|
||||||
|
description: "Manually assign players to groups, overriding role mappings.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.assignment.update",
|
||||||
|
title: "Update Assignments",
|
||||||
|
description: "Modify existing manual group assignments.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.assignment.delete",
|
||||||
|
title: "Delete Assignments",
|
||||||
|
description: "Remove manual group assignments.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Role mapping permissions
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "exp_groups.role_mapping.get",
|
||||||
|
title: "Get Role Mappings",
|
||||||
|
description: "Retrieve a specific role mapping rule.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.role_mapping.list",
|
||||||
|
title: "List Role Mappings",
|
||||||
|
description: "List all role mapping rules.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.role_mapping.subscribe",
|
||||||
|
title: "Subscribe to Role Mapping Updates",
|
||||||
|
description: "Receive updates when role mapping rules change.",
|
||||||
|
grantByDefault: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.role_mapping.create",
|
||||||
|
title: "Create Role Mappings",
|
||||||
|
description: "Create rules that map user roles to Factorio permission groups.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.role_mapping.update",
|
||||||
|
title: "Update Role Mappings",
|
||||||
|
description: "Modify existing role mapping rules.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_groups.role_mapping.delete",
|
||||||
|
title: "Delete Role Mappings",
|
||||||
|
description: "Delete role mapping rules.",
|
||||||
|
grantByDefault: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
instanceConfigFields: {
|
instanceConfigFields: {
|
||||||
"exp_groups.sync_mode": {
|
"exp_groups.sync_mode": {
|
||||||
description: "Synchronize permission groups with the controller",
|
description: "Synchronize permission groups with the controller",
|
||||||
@@ -174,7 +176,7 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
controllerEntrypoint: "./dist/node/controller",
|
controllerEntrypoint: "./dist/node/controller.js",
|
||||||
controllerConfigFields: {
|
controllerConfigFields: {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BaseInstancePlugin } from "@clusterio/host";
|
import { BaseInstancePlugin } from "@clusterio/host";
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
|
|
||||||
export type IpcGroupUpdated = {
|
export type IpcGroupUpdated = {
|
||||||
group_name: string,
|
group_name: string,
|
||||||
|
|||||||
@@ -1,6 +1,30 @@
|
|||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import { Type, Static } from "@sinclair/typebox";
|
import { Type, Static } from "@sinclair/typebox";
|
||||||
|
|
||||||
|
// Declared here rather than in index.ts because the browser project cannot include index.ts, which re-exports controller.ts
|
||||||
|
declare module "@clusterio/lib" {
|
||||||
|
export interface Permissions {
|
||||||
|
"exp_groups.group.get": never;
|
||||||
|
"exp_groups.group.list": never;
|
||||||
|
"exp_groups.group.subscribe": never;
|
||||||
|
"exp_groups.group.create": never;
|
||||||
|
"exp_groups.group.update": never;
|
||||||
|
"exp_groups.group.delete": never;
|
||||||
|
"exp_groups.assignment.get": never;
|
||||||
|
"exp_groups.assignment.list": never;
|
||||||
|
"exp_groups.assignment.subscribe": never;
|
||||||
|
"exp_groups.assignment.create": never;
|
||||||
|
"exp_groups.assignment.update": never;
|
||||||
|
"exp_groups.assignment.delete": never;
|
||||||
|
"exp_groups.role_mapping.get": never;
|
||||||
|
"exp_groups.role_mapping.list": never;
|
||||||
|
"exp_groups.role_mapping.subscribe": never;
|
||||||
|
"exp_groups.role_mapping.create": never;
|
||||||
|
"exp_groups.role_mapping.update": never;
|
||||||
|
"exp_groups.role_mapping.delete": never;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Data records
|
Data records
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production"
|
"prepare": "tsc --build && webpack-cli --env production"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useContext, useEffect } from "react";
|
|||||||
import { Modal, Form, Select } from "antd";
|
import { Modal, Form, Select } from "antd";
|
||||||
|
|
||||||
import { ControlContext, useUsers } from "@clusterio/web_ui";
|
import { ControlContext, useUsers } from "@clusterio/web_ui";
|
||||||
import * as messages from "../../messages";
|
import * as messages from "../../messages.js";
|
||||||
import type { WebPlugin } from "..";
|
import type { WebPlugin } from "..";
|
||||||
|
|
||||||
export default function AssignmentForm({ open, setOpen, initial }: {
|
export default function AssignmentForm({ open, setOpen, initial }: {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Table, Button, Space, Input, InputRef } from "antd";
|
|||||||
import { EditOutlined, SearchOutlined } from "@ant-design/icons";
|
import { EditOutlined, SearchOutlined } from "@ant-design/icons";
|
||||||
|
|
||||||
import { ControlContext, useAccount } from "@clusterio/web_ui";
|
import { ControlContext, useAccount } from "@clusterio/web_ui";
|
||||||
import { AssignmentDeleteRequest, AssignmentRecord } from "../../messages";
|
import { AssignmentDeleteRequest, AssignmentRecord } from "../../messages.js";
|
||||||
import type { WebPlugin } from "..";
|
import type { WebPlugin } from "..";
|
||||||
|
|
||||||
import AssignmentForm from "./AssignmentForm";
|
import AssignmentForm from "./AssignmentForm";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Modal, Form, Input, Switch } from "antd";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { ControlContext } from "@clusterio/web_ui";
|
import { ControlContext } from "@clusterio/web_ui";
|
||||||
import * as messages from "../../messages";
|
import * as messages from "../../messages.js";
|
||||||
|
|
||||||
export default function GroupForm({ open, setOpen }: {
|
export default function GroupForm({ open, setOpen }: {
|
||||||
open: boolean,
|
open: boolean,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Button, Checkbox, Input, Space, Spin, Alert } from "antd";
|
|||||||
import { ControlContext, useAccount, useDefaultModPack, PageLayout, PageHeader, notifyErrorHandler } from "@clusterio/web_ui";
|
import { ControlContext, useAccount, useDefaultModPack, PageLayout, PageHeader, notifyErrorHandler } from "@clusterio/web_ui";
|
||||||
import DeletedConfirm from "./DeleteConfirm";
|
import DeletedConfirm from "./DeleteConfirm";
|
||||||
|
|
||||||
import * as messages from "../../messages";
|
import * as messages from "../../messages.js";
|
||||||
import type { WebPlugin } from "..";
|
import type { WebPlugin } from "..";
|
||||||
|
|
||||||
const DOMAIN_MAPPING = {
|
const DOMAIN_MAPPING = {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Table } from "antd";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { ControlContext } from "@clusterio/web_ui";
|
import { ControlContext } from "@clusterio/web_ui";
|
||||||
import { GroupRecord } from "../../messages";
|
import { GroupRecord } from "../../messages.js";
|
||||||
import type { WebPlugin } from "..";
|
import type { WebPlugin } from "..";
|
||||||
|
|
||||||
import GroupForm from "./GroupForm";
|
import GroupForm from "./GroupForm";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useContext, useEffect } from "react";
|
|||||||
import { Modal, Form, Select, InputNumber, Switch, Alert } from "antd";
|
import { Modal, Form, Select, InputNumber, Switch, Alert } from "antd";
|
||||||
|
|
||||||
import { ControlContext, useRoles } from "@clusterio/web_ui";
|
import { ControlContext, useRoles } from "@clusterio/web_ui";
|
||||||
import { RoleMappingRecord, RoleMappingCreateRequest, RoleMappingUpdateRequest } from "../../messages";
|
import { RoleMappingRecord, RoleMappingCreateRequest, RoleMappingUpdateRequest } from "../../messages.js";
|
||||||
import type { WebPlugin } from "..";
|
import type { WebPlugin } from "..";
|
||||||
|
|
||||||
export default function RoleMappingForm({ open, setOpen, initial }: {
|
export default function RoleMappingForm({ open, setOpen, initial }: {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Table, Button, Space, Tag } from "antd";
|
|||||||
import { EditOutlined } from "@ant-design/icons";
|
import { EditOutlined } from "@ant-design/icons";
|
||||||
|
|
||||||
import { ControlContext, useAccount, useRoles } from "@clusterio/web_ui";
|
import { ControlContext, useAccount, useRoles } from "@clusterio/web_ui";
|
||||||
import { RoleMappingRecord, RoleMappingDeleteRequest } from "../../messages";
|
import { RoleMappingRecord, RoleMappingDeleteRequest } from "../../messages.js";
|
||||||
import type { WebPlugin } from "..";
|
import type { WebPlugin } from "..";
|
||||||
|
|
||||||
import RoleMappingForm from "./RoleMappingForm";
|
import RoleMappingForm from "./RoleMappingForm";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useState, useCallback, useSyncExternalStore } from "react";
|
|||||||
import { BaseWebPlugin, PageLayout, PageHeader, useAccount, SectionHeader } from "@clusterio/web_ui";
|
import { BaseWebPlugin, PageLayout, PageHeader, useAccount, SectionHeader } from "@clusterio/web_ui";
|
||||||
import { Button } from "antd";
|
import { Button } from "antd";
|
||||||
|
|
||||||
import * as messages from "../messages";
|
import * as messages from "../messages.js";
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
import GroupsTable from "./components/GroupsTable";
|
import GroupsTable from "./components/GroupsTable";
|
||||||
|
|||||||
+1
-1
@@ -4,5 +4,5 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
name: "exp_gui",
|
name: "exp_gui",
|
||||||
title: "exp_gui",
|
title: "exp_gui",
|
||||||
description: "Example Description. Plugin. Change me in index.ts",
|
description: "Example Description. Plugin. Change me in index.ts",
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production"
|
"prepare": "tsc --build && webpack-cli --env production"
|
||||||
|
|||||||
+1
-1
@@ -4,5 +4,5 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
name: "exp_legacy",
|
name: "exp_legacy",
|
||||||
title: "exp_legacy",
|
title: "exp_legacy",
|
||||||
description: "Example Description. Plugin. Change me in index.ts",
|
description: "Example Description. Plugin. Change me in index.ts",
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production"
|
"prepare": "tsc --build && webpack-cli --env production"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BaseControllerPlugin, InstanceRecord } from "@clusterio/controller";
|
import { BaseControllerPlugin, InstanceRecord } from "@clusterio/controller";
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
import * as path from "node:path";
|
import * as path from "node:path";
|
||||||
|
|
||||||
export class ControllerPlugin extends BaseControllerPlugin {
|
export class ControllerPlugin extends BaseControllerPlugin {
|
||||||
|
|||||||
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
|
|
||||||
export * from "./messages";
|
export * from "./messages.js";
|
||||||
export type { ControllerPlugin } from "./controller";
|
export type { ControllerPlugin } from "./controller.js";
|
||||||
|
|
||||||
declare module "@clusterio/lib" {
|
declare module "@clusterio/lib" {
|
||||||
export interface InstanceConfigFields {
|
export interface InstanceConfigFields {
|
||||||
@@ -35,7 +35,7 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
messages.AssignmentUpdateRequest,
|
messages.AssignmentUpdateRequest,
|
||||||
],
|
],
|
||||||
|
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
instanceConfigFields: {
|
instanceConfigFields: {
|
||||||
"exp_roles.sync_mode": {
|
"exp_roles.sync_mode": {
|
||||||
description: "Synchronize in game roles with the controller",
|
description: "Synchronize in game roles with the controller",
|
||||||
@@ -45,7 +45,7 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
controllerEntrypoint: "./dist/node/controller",
|
controllerEntrypoint: "./dist/node/controller.js",
|
||||||
controllerConfigFields: {
|
controllerConfigFields: {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BaseInstancePlugin } from "@clusterio/host";
|
import { BaseInstancePlugin } from "@clusterio/host";
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
|
|
||||||
/** Sent by the lua side when roles are changed in game. */
|
/** Sent by the lua side when roles are changed in game. */
|
||||||
export type IpcAssignmentUpdate = {
|
export type IpcAssignmentUpdate = {
|
||||||
|
|||||||
@@ -5,10 +5,11 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --env production",
|
||||||
"test": "tap --disable-coverage --allow-empty-coverage test/*.test.js",
|
"test": "tap --type-strip-only --disable-coverage --allow-empty-coverage test/*.test.js",
|
||||||
"coverage": "tap --coverage-report=text test/*.test.js"
|
"coverage": "tap --coverage-report=text test/*.test.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
"use strict";
|
import t from "tap";
|
||||||
const t = require("tap");
|
import * as lib from "@clusterio/lib";
|
||||||
const lib = require("@clusterio/lib");
|
import { Controller } from "@clusterio/controller";
|
||||||
const { Controller } = require("@clusterio/controller");
|
import { ControllerPlugin } from "../dist/node/controller.js";
|
||||||
const { ControllerPlugin } = require("../dist/node/controller");
|
import * as messages from "../dist/node/messages.js";
|
||||||
const messages = require("../dist/node/messages");
|
|
||||||
|
|
||||||
// The controller validates message classes against the link registry
|
// The controller validates message classes against the link registry
|
||||||
lib.Link.register(messages.RoleUpdatedEvent);
|
lib.Link.register(messages.RoleUpdatedEvent);
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
"use strict";
|
import t from "tap";
|
||||||
const t = require("tap");
|
import * as lib from "@clusterio/lib";
|
||||||
const lib = require("@clusterio/lib");
|
import { Instance } from "@clusterio/host";
|
||||||
const { Instance } = require("@clusterio/host");
|
import { InstancePlugin } from "../dist/node/instance.js";
|
||||||
const { InstancePlugin } = require("../dist/node/instance");
|
import { plugin as pluginDeclaration } from "../dist/node/index.js";
|
||||||
const { plugin: pluginDeclaration } = require("../dist/node/index");
|
import * as messages from "../dist/node/messages.js";
|
||||||
const messages = require("../dist/node/messages");
|
|
||||||
|
|
||||||
// The instance validates message classes against the link registry, and the
|
// The instance validates message classes against the link registry, and the
|
||||||
// plugin's config fields must be defined before an InstanceConfig can set them
|
// plugin's config fields must be defined before an InstanceConfig can set them
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use strict";
|
import t from "tap";
|
||||||
const t = require("tap");
|
import * as messages from "../dist/node/messages.js";
|
||||||
const messages = require("../dist/node/messages");
|
import { testMatrix, testRoundTripJsonSerialisable } from "../../test/common.js";
|
||||||
const { testMatrix, testRoundTripJsonSerialisable } = require("../../test/common");
|
|
||||||
|
|
||||||
const fullMeta = new messages.RoleMetaRecord(
|
const fullMeta = new messages.RoleMetaRecord(
|
||||||
7, 3, 1, "Mod", "[Mod]", new messages.RoleColor(1, 2, 3), 3600000, true, 12345, false,
|
7, 3, 1, "Mod", "[Mod]", new messages.RoleColor(1, 2, 3), 3600000, true, 12345, false,
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
"use strict";
|
import path from "node:path";
|
||||||
const path = require("node:path");
|
import t from "tap";
|
||||||
const t = require("tap");
|
import { reportLuaTests } from "../../test/lua/runner.js";
|
||||||
const { reportLuaTests } = require("../../test/lua/runner");
|
|
||||||
|
|
||||||
const envFile = path.join(__dirname, "module", "env.lua");
|
const envFile = path.join(import.meta.dirname, "module", "env.lua");
|
||||||
|
|
||||||
// Each file runs in its own lua state, and each test in a fresh environment
|
// Each file runs in its own lua state, and each test in a fresh environment
|
||||||
t.test("control.lua", t2 => {
|
t.test("control.lua", t2 => {
|
||||||
for (const file of ["lookup.lua", "players.lua", "assignment.lua", "sync.lua", "holders.lua"]) {
|
for (const file of ["lookup.lua", "players.lua", "assignment.lua", "sync.lua", "holders.lua"]) {
|
||||||
t2.test(file, t3 => reportLuaTests(t3, envFile, path.join(__dirname, "module", file)));
|
t2.test(file, t3 => reportLuaTests(t3, envFile, path.join(import.meta.dirname, "module", file)));
|
||||||
}
|
}
|
||||||
t2.end();
|
t2.end();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Button, Col, ColorPicker, Form, Input, InputNumber, Row, Switch, Toolti
|
|||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import { ControlContext, SectionHeader, useAccount, notifyErrorHandler } from "@clusterio/web_ui";
|
import { ControlContext, SectionHeader, useAccount, notifyErrorHandler } from "@clusterio/web_ui";
|
||||||
|
|
||||||
import { RoleColor, RoleMetaRecord, RoleMetaUpdateRequest } from "../../messages";
|
import { RoleColor, RoleMetaRecord, RoleMetaUpdateRequest } from "../../messages.js";
|
||||||
import type { WebPlugin } from "..";
|
import type { WebPlugin } from "..";
|
||||||
|
|
||||||
const MS_PER_HOUR = 3600000;
|
const MS_PER_HOUR = 3600000;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useCallback, useSyncExternalStore } from "react";
|
|||||||
import { BaseWebPlugin } from "@clusterio/web_ui";
|
import { BaseWebPlugin } from "@clusterio/web_ui";
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "../messages";
|
import * as messages from "../messages.js";
|
||||||
|
|
||||||
import RoleProperties from "./components/RoleProperties";
|
import RoleProperties from "./components/RoleProperties";
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { RoleMetaRecord, type ControllerPlugin as RolesPlugin } from "@expcluste
|
|||||||
import {
|
import {
|
||||||
GroupRecord, GroupPermissions, RoleMappingRecord, type ControllerPlugin as GroupsPlugin,
|
GroupRecord, GroupPermissions, RoleMappingRecord, type ControllerPlugin as GroupsPlugin,
|
||||||
} from "@expcluster/permission-groups";
|
} from "@expcluster/permission-groups";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
import { SeedRole, SeedGroup, seedRoles, seedGroups, flattenSeedPermissions } from "./seed";
|
import { SeedRole, SeedGroup, seedRoles, seedGroups, flattenSeedPermissions } from "./seed.js";
|
||||||
|
|
||||||
export class ControllerPlugin extends BaseControllerPlugin {
|
export class ControllerPlugin extends BaseControllerPlugin {
|
||||||
async init() {
|
async init() {
|
||||||
|
|||||||
+29
-25
@@ -1,41 +1,45 @@
|
|||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
import * as messages from "./messages";
|
import * as messages from "./messages.js";
|
||||||
|
import { permissions as scenarioPermissions, type ScenarioPermissionName } from "./permissions.js";
|
||||||
// Defines a permission for every in game action and role flag used by the scenario
|
|
||||||
import "./permissions";
|
|
||||||
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_scenario.config.view",
|
|
||||||
title: "View ExpScenario Config",
|
|
||||||
description: "View the config for all submodules of ExpScenario",
|
|
||||||
});
|
|
||||||
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_scenario.config.edit",
|
|
||||||
title: "Edit ExpScenario Config",
|
|
||||||
description: "Edit the config for all submodules of ExpScenario",
|
|
||||||
});
|
|
||||||
|
|
||||||
lib.definePermission({
|
|
||||||
name: "exp_scenario.seed",
|
|
||||||
title: "Seed ExpScenario roles and groups",
|
|
||||||
description: "Create the roles and permission groups the scenario shipped with",
|
|
||||||
});
|
|
||||||
|
|
||||||
declare module "@clusterio/lib" {
|
declare module "@clusterio/lib" {
|
||||||
|
// Everything checked in game through exp_roles, plus the permissions checked on the controller
|
||||||
|
export interface Permissions extends Record<ScenarioPermissionName, never> {
|
||||||
|
"exp_scenario.config.view": never;
|
||||||
|
"exp_scenario.config.edit": never;
|
||||||
|
"exp_scenario.seed": never;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const plugin: lib.PluginDeclaration = {
|
export const plugin: lib.PluginDeclaration = {
|
||||||
name: "exp_scenario",
|
name: "exp_scenario",
|
||||||
title: "exp_scenario",
|
title: "exp_scenario",
|
||||||
description: "Example Description. Plugin. Change me in index.ts",
|
description: "Example Description. Plugin. Change me in index.ts",
|
||||||
controllerEntrypoint: "./dist/node/controller",
|
controllerEntrypoint: "./dist/node/controller.js",
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
|
|
||||||
messages: [
|
messages: [
|
||||||
messages.SeedRequest,
|
messages.SeedRequest,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
permissions: [
|
||||||
|
...scenarioPermissions,
|
||||||
|
{
|
||||||
|
name: "exp_scenario.config.view",
|
||||||
|
title: "View ExpScenario Config",
|
||||||
|
description: "View the config for all submodules of ExpScenario",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_scenario.config.edit",
|
||||||
|
title: "Edit ExpScenario Config",
|
||||||
|
description: "Edit the config for all submodules of ExpScenario",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exp_scenario.seed",
|
||||||
|
title: "Seed ExpScenario roles and groups",
|
||||||
|
description: "Create the roles and permission groups the scenario shipped with",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
webEntrypoint: "./web",
|
webEntrypoint: "./web",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,10 +5,11 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --env production",
|
||||||
"test": "tap --disable-coverage --allow-empty-coverage test/*.test.js",
|
"test": "tap --type-strip-only --disable-coverage --allow-empty-coverage test/*.test.js",
|
||||||
"coverage": "tap --coverage-report=text test/*.test.js"
|
"coverage": "tap --coverage-report=text test/*.test.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as lib from "@clusterio/lib";
|
import type * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permissions checked by the scenario in game through exp_roles.
|
* Permissions checked by the scenario in game through exp_roles.
|
||||||
@@ -7,9 +7,9 @@ import * as lib from "@clusterio/lib";
|
|||||||
* underscores, see module/commands/_authorities.lua. Everything else is checked
|
* underscores, see module/commands/_authorities.lua. Everything else is checked
|
||||||
* by name at its call site.
|
* by name at its call site.
|
||||||
*/
|
*/
|
||||||
type Definition = [name: string, title: string, description: string, grantByDefault?: boolean];
|
type Definition<Name extends string = string> = readonly [name: Name, title: string, description: string, grantByDefault?: boolean];
|
||||||
|
|
||||||
const definitions: Definition[] = [
|
const definitions = [
|
||||||
["exp_scenario.bypass.deconstruction_log", "Deconstruction log bypass", "Be excluded from the deconstruction log."],
|
["exp_scenario.bypass.deconstruction_log", "Deconstruction log bypass", "Be excluded from the deconstruction log."],
|
||||||
["exp_scenario.bypass.entity_protection", "Bypass entity protection", "Remove entities that the protection filter would block."],
|
["exp_scenario.bypass.entity_protection", "Bypass entity protection", "Remove entities that the protection filter would block."],
|
||||||
["exp_scenario.bypass.nuke_protection", "Bypass nuke protection", "Use nukes without the nuke protection restrictions."],
|
["exp_scenario.bypass.nuke_protection", "Bypass nuke protection", "Use nukes without the nuke protection restrictions."],
|
||||||
@@ -118,8 +118,12 @@ const definitions: Definition[] = [
|
|||||||
["exp_scenario.player.admin", "Factorio admin", "Be promoted to Factorio admin while holding a role with this permission."],
|
["exp_scenario.player.admin", "Factorio admin", "Be promoted to Factorio admin while holding a role with this permission."],
|
||||||
["exp_scenario.player.instant_respawn", "Instant respawn", "Respawn after two seconds instead of the default delay."],
|
["exp_scenario.player.instant_respawn", "Instant respawn", "Respawn after two seconds instead of the default delay."],
|
||||||
["exp_scenario.player.spectator", "Spectator", "Remove the zoom to world noise effect, as Factorio does for spectators."],
|
["exp_scenario.player.spectator", "Spectator", "Remove the zoom to world noise effect, as Factorio does for spectators."],
|
||||||
];
|
] as const satisfies readonly Definition[];
|
||||||
|
|
||||||
for (const [name, title, description, grantByDefault] of definitions) {
|
/** Name of a permission defined by the scenario, added to lib.Permissions in index.ts. */
|
||||||
lib.definePermission({ name, title, description, grantByDefault });
|
export type ScenarioPermissionName = (typeof definitions)[number][0];
|
||||||
}
|
|
||||||
|
export const permissions = definitions.map((definition: Definition<ScenarioPermissionName>): lib.PermissionDefinition => {
|
||||||
|
const [name, title, description, grantByDefault] = definition;
|
||||||
|
return { name, title, description, grantByDefault };
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type * as lib from "@clusterio/lib";
|
||||||
import { RoleColor } from "@expcluster/roles";
|
import { RoleColor } from "@expcluster/roles";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +20,7 @@ export interface SeedRole {
|
|||||||
isAdmin?: boolean;
|
isAdmin?: boolean;
|
||||||
/** Name of the role whose permissions are also granted, applied recursively. */
|
/** Name of the role whose permissions are also granted, applied recursively. */
|
||||||
parent?: string;
|
parent?: string;
|
||||||
permissions: string[];
|
permissions: lib.PermissionName[];
|
||||||
/**
|
/**
|
||||||
* Name of the seed group holders are placed in by their highest role.
|
* Name of the seed group holders are placed in by their highest role.
|
||||||
* Without one the holders stay in Factorio's Default group.
|
* Without one the holders stay in Factorio's Default group.
|
||||||
@@ -329,7 +330,7 @@ export const seedGroups: SeedGroup[] = [
|
|||||||
|
|
||||||
/** The permissions a seed role grants, including those of its parents. */
|
/** The permissions a seed role grants, including those of its parents. */
|
||||||
export function flattenSeedPermissions(role: SeedRole, roles = seedRoles) {
|
export function flattenSeedPermissions(role: SeedRole, roles = seedRoles) {
|
||||||
const permissions = new Set<string>();
|
const permissions = new Set<lib.PermissionName>();
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
let current: SeedRole | undefined = role;
|
let current: SeedRole | undefined = role;
|
||||||
while (current && !seen.has(current.name)) {
|
while (current && !seen.has(current.name)) {
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
"use strict";
|
import t from "tap";
|
||||||
const t = require("tap");
|
import * as lib from "@clusterio/lib";
|
||||||
const lib = require("@clusterio/lib");
|
import { Controller } from "@clusterio/controller";
|
||||||
const { Controller } = require("@clusterio/controller");
|
import { ControllerPlugin } from "../dist/node/controller.js";
|
||||||
const { ControllerPlugin } = require("../dist/node/controller");
|
import * as messages from "../dist/node/messages.js";
|
||||||
const messages = require("../dist/node/messages");
|
import { seedRoles, seedGroups } from "../dist/node/seed.js";
|
||||||
const { seedRoles, seedGroups } = require("../dist/node/seed");
|
import * as roles from "@expcluster/roles";
|
||||||
const roles = require("@expcluster/roles");
|
import * as groups from "@expcluster/permission-groups";
|
||||||
const groups = require("@expcluster/permission-groups");
|
import { ControllerPlugin as RolesPlugin } from "@expcluster/roles/dist/node/controller.js";
|
||||||
const { ControllerPlugin: RolesPlugin } = require("@expcluster/roles/dist/node/controller");
|
import { ControllerPlugin as GroupsPlugin } from "@expcluster/permission-groups/dist/node/controller.js";
|
||||||
const { ControllerPlugin: GroupsPlugin } = require("@expcluster/permission-groups/dist/node/controller");
|
import { GroupRecord, GroupPermissions, RoleMappingRecord } from "@expcluster/permission-groups";
|
||||||
const { GroupRecord, GroupPermissions, RoleMappingRecord } = require("@expcluster/permission-groups");
|
|
||||||
|
|
||||||
// Importing this defines the permissions the seed grants
|
import { plugin } from "../dist/node/index.js";
|
||||||
require("../dist/node/permissions");
|
|
||||||
|
// Registering the plugin defines the permissions the seed grants
|
||||||
|
lib.registerPluginPermissions([plugin]);
|
||||||
|
|
||||||
// The controller validates message classes against the link registry
|
// The controller validates message classes against the link registry
|
||||||
for (const Message of [messages.SeedRequest, ...roles.plugin.messages, ...groups.plugin.messages]) {
|
for (const Message of [messages.SeedRequest, ...roles.plugin.messages, ...groups.plugin.messages]) {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
"use strict";
|
import t from "tap";
|
||||||
const t = require("tap");
|
import * as lib from "@clusterio/lib";
|
||||||
const lib = require("@clusterio/lib");
|
import { seedRoles, seedGroups, flattenSeedPermissions } from "../dist/node/seed.js";
|
||||||
const { seedRoles, seedGroups, flattenSeedPermissions } = require("../dist/node/seed");
|
|
||||||
|
|
||||||
// Importing this defines the permissions the seed grants
|
import { plugin } from "../dist/node/index.js";
|
||||||
require("../dist/node/permissions");
|
|
||||||
|
// Registering the plugin defines the permissions the seed grants
|
||||||
|
lib.registerPluginPermissions([plugin]);
|
||||||
|
|
||||||
t.test("seedRoles[] grant only defined permissions", t2 => {
|
t.test("seedRoles[] grant only defined permissions", t2 => {
|
||||||
for (const role of seedRoles) {
|
for (const role of seedRoles) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"extends": "../tsconfig.browser.json",
|
"extends": "../tsconfig.browser.json",
|
||||||
"include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ],
|
"include": [ "web/**/*.tsx", "web/**/*.ts", "index.ts", "messages.ts", "permissions.ts", "package.json" ],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Button, Popconfirm } from "antd";
|
|||||||
|
|
||||||
import { ControlContext, SectionHeader, useAccount, notifyErrorHandler } from "@clusterio/web_ui";
|
import { ControlContext, SectionHeader, useAccount, notifyErrorHandler } from "@clusterio/web_ui";
|
||||||
|
|
||||||
import { SeedRequest } from "../../messages";
|
import { SeedRequest } from "../../messages.js";
|
||||||
|
|
||||||
/** Button on the roles page which creates the roles and permission groups the scenario shipped with. */
|
/** Button on the roles page which creates the roles and permission groups the scenario shipped with. */
|
||||||
export default function Seed() {
|
export default function Seed() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
title: "ExpGaming - Server UPS",
|
title: "ExpGaming - Server UPS",
|
||||||
description: "Clusterio plugin providing in game server ups counter",
|
description: "Clusterio plugin providing in game server ups counter",
|
||||||
|
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
instanceConfigFields: {
|
instanceConfigFields: {
|
||||||
"exp_server_ups.update_interval": {
|
"exp_server_ups.update_interval": {
|
||||||
title: "Update Interval",
|
title: "Update Interval",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production"
|
"prepare": "tsc --build && webpack-cli --env production"
|
||||||
|
|||||||
+1
-1
@@ -4,5 +4,5 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
name: "exp_util",
|
name: "exp_util",
|
||||||
title: "ExpGaming Module Utilities",
|
title: "ExpGaming Module Utilities",
|
||||||
description: "Provides extensions and overrides of base Lua library functions, and provides utility modules for improved module compatibly",
|
description: "Provides extensions and overrides of base Lua library functions, and provides utility modules for improved module compatibly",
|
||||||
instanceEntrypoint: "./dist/node/instance",
|
instanceEntrypoint: "./dist/node/instance.js",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "explosivegaming/ExpCluster",
|
"repository": "explosivegaming/ExpCluster",
|
||||||
|
"type": "module",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production"
|
"prepare": "tsc --build && webpack-cli --env production"
|
||||||
|
|||||||
+2
-3
@@ -1,5 +1,4 @@
|
|||||||
"use strict";
|
import { compile } from "@clusterio/lib";
|
||||||
const { compile } = require("@clusterio/lib");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a flat array of tests from a matrix of inputs.
|
* Generate a flat array of tests from a matrix of inputs.
|
||||||
@@ -49,7 +48,7 @@ function testRoundTripJsonSerialisable(t, Class, tests) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export {
|
||||||
testMatrix,
|
testMatrix,
|
||||||
testRoundTripJsonSerialisable,
|
testRoundTripJsonSerialisable,
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-6
@@ -1,7 +1,6 @@
|
|||||||
"use strict";
|
import path from "node:path";
|
||||||
const path = require("node:path");
|
import fs from "node:fs";
|
||||||
const fs = require("node:fs");
|
import { createRequire } from "node:module";
|
||||||
const { lua, lauxlib, lualib, to_luastring, to_jsstring } = require("fengari");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run one lua test file in its own lua state and return its results.
|
* Run one lua test file in its own lua state and return its results.
|
||||||
@@ -21,6 +20,8 @@ const { lua, lauxlib, lualib, to_luastring, to_jsstring } = require("fengari");
|
|||||||
* @returns {{ name: string, ok: boolean, detail?: string }[]}
|
* @returns {{ name: string, ok: boolean, detail?: string }[]}
|
||||||
*/
|
*/
|
||||||
function runLuaTests(envFile, testFile) {
|
function runLuaTests(envFile, testFile) {
|
||||||
|
// fengari is a devDependency of the plugin whose tests run, so resolve it from there
|
||||||
|
const { lua, lauxlib, lualib, to_luastring, to_jsstring } = createRequire(testFile)("fengari");
|
||||||
const L = lauxlib.luaL_newstate();
|
const L = lauxlib.luaL_newstate();
|
||||||
lualib.luaL_openlibs(L);
|
lualib.luaL_openlibs(L);
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ function runLuaTests(envFile, testFile) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
load(envFile);
|
load(envFile);
|
||||||
lua.lua_pushstring(L, to_luastring(__dirname));
|
lua.lua_pushstring(L, to_luastring(import.meta.dirname));
|
||||||
call();
|
call();
|
||||||
|
|
||||||
// The environment stays on the stack and is passed to the test chunk
|
// The environment stays on the stack and is passed to the test chunk
|
||||||
@@ -60,4 +61,4 @@ function reportLuaTests(t, envFile, testFile) {
|
|||||||
t.end();
|
t.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { runLuaTests, reportLuaTests };
|
export { runLuaTests, reportLuaTests };
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"extends": "./tsconfig.base.json",
|
"extends": "./tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["es2023"],
|
"lib": ["es2023"],
|
||||||
"module": "node16",
|
"module": "nodenext",
|
||||||
"moduleResolution": "node16",
|
"moduleResolution": "node16",
|
||||||
"target": "es2022",
|
"target": "es2022",
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user