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 { debugDump } from './HexUtil.js'
import { Buffer} from 'node:buffer' import { Buffer } from 'node:buffer'
export default class Logger { export default class Logger {
constructor () { constructor () {

View File

@ -10,7 +10,7 @@ export default class asa extends Epic {
this.deploymentId = 'ad9a8feffb3b4b2ca315546f038c3ae2' this.deploymentId = 'ad9a8feffb3b4b2ca315546f038c3ae2'
} }
async run(state) { async run (state) {
await super.run(state) await super.run(state)
state.version = state.raw.attributes.BUILDID_s + '.' + state.raw.attributes.MINORBUILDID_s 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 state.raw.dlcEnabled = true
} }
if (tag.includes('privHive')) { if (tag.includes('privHive')) {
state.raw.privateHive = true; state.raw.privateHive = true
} }
if (tag.includes('external')) { if (tag.includes('external')) {
state.raw.external = true; state.raw.external = true
} }
if (tag.includes(':')) { if (tag.includes(':')) {
state.raw.time = tag state.raw.time = tag

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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