chore: run eslint --fix

This commit is contained in:
CosminPerRam 2024-06-29 23:27:19 +03:00
parent 2c8fef316b
commit a5187f70f9
10 changed files with 61 additions and 62 deletions

View File

@ -1,5 +1,5 @@
import { debugDump } from './HexUtil.js'
import { Buffer} from 'node:buffer'
import { Buffer } from 'node:buffer'
export default class Logger {
constructor () {

View File

@ -10,7 +10,7 @@ export default class asa extends Epic {
this.deploymentId = 'ad9a8feffb3b4b2ca315546f038c3ae2'
}
async run(state) {
async run (state) {
await super.run(state)
state.version = state.raw.attributes.BUILDID_s + '.' + state.raw.attributes.MINORBUILDID_s
}

View File

@ -80,10 +80,10 @@ export default class dayz extends valve {
state.raw.dlcEnabled = true
}
if (tag.includes('privHive')) {
state.raw.privateHive = true;
state.raw.privateHive = true
}
if (tag.includes('external')) {
state.raw.external = true;
state.raw.external = true
}
if (tag.includes(':')) {
state.raw.time = tag

View File

@ -1,7 +1,7 @@
import samp from './samp.js'
export default class gtasao extends samp {
constructor() {
constructor () {
super()
this.isOmp = true
}

View File

@ -1,12 +1,12 @@
import Core from './core.js'
export default class minetest extends Core {
constructor() {
constructor () {
super()
this.usedTcp = true
}
async run(state) {
async run (state) {
const servers = await this.request({
url: 'https://servers.minetest.net/list',
responseType: 'json'

View File

@ -7,7 +7,7 @@ export default class quake1 extends quake2 {
this.isQuake1 = true
}
async run(state) {
async run (state) {
await super.run(state)
if ('*version' in state.raw) state.version = state.raw['*version']
}

View File

@ -1,12 +1,12 @@
import Core from './core.js'
export default class ragemp extends Core {
constructor() {
constructor () {
super()
this.usedTcp = true
}
async run(state) {
async run (state) {
const results = await this.request({
url: 'https://cdn.rage.mp/master/v2/',
responseType: 'json'

View File

@ -17,13 +17,12 @@ if (argv._.length >= 1) {
const gamedig = new GameDig(options)
let protocolList = []
const protocolList = []
Object.keys(protocols).forEach((key) => protocolList.push(key))
const services = ['discord', 'beammpmaster', 'beammp', 'teamspeak2', 'teamspeak3']
const protocolListFiltered = protocolList.filter((protocol) => !services.includes(protocol))
const run = async () => {
for (const protocol of protocolListFiltered) {
try {

View File

@ -1,11 +1,11 @@
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import assert from "node:assert";
import { mkdirSync, copyFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import process from "node:process";
import { spawnSync } from 'node:child_process'
import assert from 'node:assert'
import { mkdirSync, copyFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import process from 'node:process'
// Generate a list of changes to "lib/games.js" where game IDs have been changed via the git history.
// Requires git to be installed.
@ -25,81 +25,81 @@ import process from "node:process";
const main = async (rootDir) => {
// Make sure CWD is the root of the repo
process.chdir(rootDir);
process.chdir(rootDir)
// Get list of commits that have modified lib/games.js
const gitLog = spawnSync(
"git",
'git',
[
"log",
"--follow",
"--format=%H",
"--diff-filter=M",
"--reverse",
"--",
"lib/games.js",
'log',
'--follow',
'--format=%H',
'--diff-filter=M',
'--reverse',
'--',
'lib/games.js'
],
{ encoding: "utf-8" }
);
{ encoding: 'utf-8' }
)
// Make a directory to store files in
mkdirSync("game_changes", { recursive: true });
mkdirSync('game_changes', { recursive: true })
const output = [];
const output = []
for (const commitHash of gitLog.stdout.split("\n")) {
if (commitHash.length === 0) continue;
for (const commitHash of gitLog.stdout.split('\n')) {
if (commitHash.length === 0) continue
// Checkout lib/games.js before the commit that changed it
assert(
spawnSync("git", ["checkout", `${commitHash}^1`, "--", "lib/games.js"])
spawnSync('git', ['checkout', `${commitHash}^1`, '--', 'lib/games.js'])
.status === 0
);
)
// We have to copy each state of the file to its own file because node caches imports
const beforeName = `game_changes/${commitHash}-before.js`;
copyFileSync("lib/games.js", beforeName);
const beforeName = `game_changes/${commitHash}-before.js`
copyFileSync('lib/games.js', beforeName)
const before = await import(path.join("../", beforeName));
const before = await import(path.join('../', beforeName))
// Checkout lib/games.js after the commit that changed it
assert(
spawnSync("git", ["checkout", `${commitHash}`, "--", "lib/games.js"])
spawnSync('git', ['checkout', `${commitHash}`, '--', 'lib/games.js'])
.status === 0
);
)
const afterName = `game_changes/${commitHash}-after.js`;
copyFileSync("lib/games.js", afterName);
const afterName = `game_changes/${commitHash}-after.js`
copyFileSync('lib/games.js', afterName)
const after = await import(path.join("../", afterName));
const after = await import(path.join('../', afterName))
// Find game IDs that were removed and added
let removed = Object.keys(before.games).filter(
(key) => !(key in after.games)
);
)
let added = Object.keys(after.games).filter(
(key) => !(key in before.games)
);
)
const changes = [];
const changes = []
for (const rm of removed) {
for (const add of added) {
const beforeGame = before.games[rm];
const afterGame = after.games[add];
const beforeGame = before.games[rm]
const afterGame = after.games[add]
// Modify game names to ignore case, spaces, and punctuation
const beforeName = beforeGame.name.toLowerCase().replace(/[^a-z]/g, "");
const afterName = afterGame.name.toLowerCase().replace(/[^a-z]/g, "");
const beforeName = beforeGame.name.toLowerCase().replace(/[^a-z]/g, '')
const afterName = afterGame.name.toLowerCase().replace(/[^a-z]/g, '')
if (
beforeGame.options.protocol === afterGame.options.protocol &&
(beforeName.includes(afterName) || afterName.includes(beforeName))
) {
changes.push([rm, add]);
removed = removed.filter((r) => r !== rm);
added = added.filter((a) => a !== add);
break;
changes.push([rm, add])
removed = removed.filter((r) => r !== rm)
added = added.filter((a) => a !== add)
break
}
}
}
@ -108,18 +108,18 @@ const main = async (rootDir) => {
hash: commitHash,
changes,
removed,
added,
});
added
})
}
// Reset the contents of lib/games.js
spawnSync("git", ["checkout", "--", "lib/games.js"]);
spawnSync('git', ['checkout', '--', 'lib/games.js'])
return output;
};
return output
}
main(
// Get the root of the repo:
// dir of bin/find-id-changes.js -> /../
path.join(path.dirname(fileURLToPath(import.meta.url)), "..")
).then((o) => console.log(JSON.stringify(o)), console.error);
path.join(path.dirname(fileURLToPath(import.meta.url)), '..')
).then((o) => console.log(JSON.stringify(o)), console.error)

View File

@ -9,7 +9,7 @@ Object.keys(games).forEach((key) => {
}
})
function hasDuplicates(obj) {
function hasDuplicates (obj) {
const uniqueSet = new Set()
for (const item of obj) {