Skip to content

Commit

Permalink
Merge branch 'tabarra:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nkyo authored Feb 10, 2025
2 parents 601c0c6 + ea3c36f commit 62cfa51
Show file tree
Hide file tree
Showing 451 changed files with 27,191 additions and 19,984 deletions.
28 changes: 0 additions & 28 deletions .deploy.config.js

This file was deleted.

54 changes: 17 additions & 37 deletions .github/workflows/locale-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,33 @@ jobs:
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Label PR and enforce base branch
- name: Enforce base branch
uses: actions/github-script@v7
with:
script: |
// console.warn('This is bugged and doesn\'t work, skip this step for now!');
// process.exit(0);
// Add the 'translation' label
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['translation']
});
console.log(JSON.stringify(context.payload.pull_request));
const { repo, owner } = context.repo;
// Get the pull request
const pull_number = context.payload.pull_request.number;
const pull_request = await github.rest.pulls.get({
owner,
repo,
pull_number
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
// Check if the base branch is 'main' or 'master'
if (pull_request.data.base.ref === 'main' || pull_request.data.base.ref === 'master') {
// Change the base branch to 'develop'
await github.rest.pulls.update({
owner,
repo,
pull_number,
base: 'develop'
});
console.error('Pull request is targeting the main branch. Please target the develop branch instead.');
process.exit(1);
}
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

- name: Run locale:check
id: locale-check
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-tagged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
with:
fetch-depth: 0

- name: Use Node.js 20
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22

- name: Download all modules
run: npm ci
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Tests for Workspaces

on:
push:
branches:
- master
pull_request:
branches:
- "**"

jobs:
run-tests:
name: "Run Unit Testing"
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Download all modules
run: npm ci

- name: Run Tests
env:
CI: true
run: npm run test --workspaces
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cache/*
dist/*
.reports/*
license_report/*
tmp_core_tsc/*
.tsc/*
*.ignore.*
/start_*.bat
monitor-*.zip
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2024 André Tabarra <[email protected]>
Copyright (c) 2019-2025 André Tabarra <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Join our Discord Server: &nbsp; <a href="https://discord.gg/AFAAXzq"><img src="https://discordapp.com/api/guilds/577993482761928734/widget.png?style=shield"></img></a>
</h4>
<p align="center">
<b>txAdmin</b> is a <b>full featured</b> web panel to Manage & Monitor your FiveM/RedM Server remotely, in use by over <strong>21.000</strong> servers worldwide at any given time.
<b>txAdmin</b> is _the_ <b>full featured</b> web panel to Manage & Monitor your FiveM/RedM Server remotely, in use by over <strong>29.000</strong> servers worldwide at any given time.
</p>
<p align="center">
<a href="https://zap-hosting.com/txadmin4" target="_blank" rel="noopener">
Expand Down Expand Up @@ -80,7 +80,6 @@ txAdmin requires to be launched from *inside* FXServer in monitor mode, to do th
- **txAdminPort:** The TCP port to use as HTTP Server. The default is `40120`.
- **txAdminInterface:** The interface to use as HTTP Server. The default is `0.0.0.0`.
- **txDataPath:** The path of the data folder. The default on Windows is `<citizen_root>/../txData` and on Linux `<citizen_root>/../../../txData`.
- **txAdminVerbose:** Set to `true` to print on the console more detailed information about errors and events. The default is `false`.

ConVar usage **example** for different port and profile:
```bash
Expand Down
1 change: 0 additions & 1 deletion core/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = {
es2017: true,
},
globals: {
globals: 'writable',
GlobalData: 'writable',
ExecuteCommand: 'readonly',
GetConvar: 'readonly',
Expand Down
12 changes: 10 additions & 2 deletions core/.npm-upgrade.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ignore": {
"open": {
"versions": "> 7.1.0",
"versions": ">7.1.0",
"reason": "Doesn't work when powershell is not in PATH or something like that."
},
"fs-extra": {
Expand Down Expand Up @@ -35,6 +35,14 @@
"slug": {
"versions": ">8",
"reason": "dropped support for node 16"
},
"boxen": {
"versions": ">7",
"reason": "dropped support for node 16"
},
"discord.js": {
"versions": ">14.11.0",
"reason": "undici sub-dependency dropped support for node 16"
}
}
}
}
24 changes: 11 additions & 13 deletions core/extras/checkPreRelease.ts → core/boot/checkPreRelease.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import humanizeDuration, { Unit } from 'humanize-duration';
import chalk from 'chalk';
import consoleFactory from '@extras/console';
import consoleFactory from '@lib/console';
import fatalError from '@lib/fatalError';
import { msToDuration } from '@lib/misc';
const console = consoleFactory('ATTENTION');


//@ts-ignore esbuild will replace TX_PRERELEASE_EXPIRATION with a string
const PRERELEASE_EXPIRATION = parseInt(TX_PRERELEASE_EXPIRATION)
const humanizeOptions = {
round: true,
units: ['d', 'h', 'm'] as Unit[],
};

const expiredError = [
'This pre-release version has expired, please update your txAdmin.',
'Bye bye 👋',
]

const printExpirationBanner = (timeUntilExpiration: number) => {
const timeLeft = humanizeDuration(timeUntilExpiration, humanizeOptions)
const timeLeft = msToDuration(timeUntilExpiration)
const timeLeftStyled = chalk.inverse(` ${timeLeft} `);
console.error('This is a pre-release version of txAdmin!');
console.error('This build is meant to be used by txAdmin beta testers.');
Expand All @@ -26,10 +29,7 @@ const cronCheckExpiration = () => {

const timeUntilExpiration = PRERELEASE_EXPIRATION - Date.now();
if (timeUntilExpiration < 0) {
console.error('This pre-release version has expired, please update your txAdmin.');
console.error('For more information: https://discord.gg/txAdmin.');
console.error('Bye bye 👋');
process.exit(400);
fatalError.Boot(11, expiredError);
} else if (timeUntilExpiration < 24 * 60 * 60 * 1000) {
printExpirationBanner(timeUntilExpiration);
}
Expand All @@ -40,9 +40,7 @@ export default () => {

const timeUntilExpiration = PRERELEASE_EXPIRATION - Date.now();
if (timeUntilExpiration < 0) {
console.error('This pre-release version has expired, please update your txAdmin.');
console.error('For more information: https://discord.gg/txAdmin.');
process.exit(401);
fatalError.Boot(10, expiredError);
}

//First warning
Expand Down
52 changes: 52 additions & 0 deletions core/boot/globalPlaceholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { txDevEnv } from "@core/globalData";
import consoleFactory from "@lib/console";
import fatalError from "@lib/fatalError";
const console = consoleFactory('GlobalPlaceholder');

//Messages
const MSG_VIOLATION = 'Global Proxy Access Violation!';
const MSG_BOOT_FAIL = 'Failed to boot due to Module Race Condition.';
const MSG_CONTACT_DEV = 'This error should never happen, please report it to the developers.';
const MSG_ERR_PARTIAL = 'Attempted to access txCore before it was initialized!';


/**
* Returns a Proxy that will throw a fatalError when accessing an uninitialized property
*/
export const getCoreProxy = (refSrc: any) => {
return new Proxy(refSrc, {
get: function (target, prop) {
// if (!txDevEnv.ENABLED && Reflect.has(target, prop)) {
// if (console.isVerbose) {
// console.majorMultilineError([
// MSG_VIOLATION,
// MSG_CONTACT_DEV,
// `Getter for ${String(prop)}`,
// ]);
// }
// return Reflect.get(target, prop).deref();
// }
fatalError.Boot(
22,
[
MSG_BOOT_FAIL,
MSG_CONTACT_DEV,
['Getter for', String(prop)],
],
new Error(MSG_ERR_PARTIAL)
);
},
set: function (target, prop, value) {
fatalError.Boot(
23,
[
MSG_BOOT_FAIL,
MSG_CONTACT_DEV,
['Setter for', String(prop)],
],
new Error(MSG_ERR_PARTIAL)
);
return true;
}
});
}
73 changes: 73 additions & 0 deletions core/boot/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const modulename = 'Setup';
import path from 'node:path';
import fs from 'node:fs';

import chalk from 'chalk';
import consoleFactory from '@lib/console';
import fatalError from '@lib/fatalError';
import { txEnv } from '@core/globalData';
import ConfigStore from '@modules/ConfigStore';
const console = consoleFactory(modulename);


/**
* Ensure the profile subfolders exist
*/
export const ensureProfileStructure = () => {
const dataPath = path.join(txEnv.profilePath, 'data');
if (!fs.existsSync(dataPath)) {
fs.mkdirSync(dataPath);
}

const logsPath = path.join(txEnv.profilePath, 'logs');
if (!fs.existsSync(logsPath)) {
fs.mkdirSync(logsPath);
}
}


/**
* Setup the profile folder structure
*/
export const setupProfile = () => {
console.log(console.DIVIDER);
//Create new profile folder
console.log('Creating new profile folder...');
try {
fs.mkdirSync(txEnv.profilePath);
const configStructure = ConfigStore.getEmptyConfigFile();
fs.writeFileSync(
path.join(txEnv.profilePath, 'config.json'),
JSON.stringify(configStructure, null, 2)
);
ensureProfileStructure();
} catch (error) {
fatalError.Boot(4, [
'Failed to set up folder structure for the new profile.',
['Path', txEnv.profilePath],
], error);
}
console.ok(`Server profile was saved in '${txEnv.profilePath}'`);

//Saving start.bat (yes, I also wish this didn't exist)
if (txEnv.osType == 'windows') {
const batFilename = `start_${txEnv.fxsVersion}_${txEnv.profile}.bat`;
try {
const fxsPath = path.join(txEnv.fxServerPath, 'FXServer.exe');
const batLines = [
//TODO: add note to not add any server convars in here
`@echo off`,
`"${fxsPath}" +set serverProfile "${txEnv.profile}"`,
`pause`
];
const batFolder = path.resolve(txEnv.fxServerPath, '..');
const batPath = path.join(batFolder, batFilename);
fs.writeFileSync(batPath, batLines.join('\r\n'));
console.ok(`You can use ${chalk.inverse(batPath)} to start this profile.`);
} catch (error) {
console.warn(`Failed to create '${batFilename}' with error:`);
console.dir(error);
}
}
console.log(console.DIVIDER);
};
Loading

0 comments on commit 62cfa51

Please sign in to comment.