Skip to content

Commit

Permalink
chore(core): small typescript fixes + formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Apr 29, 2023
1 parent 3f2530d commit 5794f89
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 32 deletions.
4 changes: 2 additions & 2 deletions core/components/PlayerDatabase/idGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const modulename = 'IDGen';
import fsp from 'node:fs/promises';
import humanizeDuration from 'humanize-duration';
import humanizeDuration, { HumanizerOptions } from 'humanize-duration';
import * as nanoidSecure from 'nanoid';
import * as nanoidNonSecure from 'nanoid/non-secure';
import consts from '@core/extras/consts';
Expand All @@ -20,7 +20,7 @@ const noIdErrorMessage = 'Unnable to generate new Random ID possibly due to the
* Prints a diagnostics message to the console that should help us identify what is the problem and the potential solution
*/
const printDiagnostics = async () => {
const humanizeOptions = {
const humanizeOptions: HumanizerOptions = {
round: true,
units: ['d', 'h', 'm'],
};
Expand Down
2 changes: 1 addition & 1 deletion core/globalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const citizenRootConvar = getConvarString('citizen_root');
if (!citizenRootConvar) {
logDie('citizen_root convar not set');
}
const fxServerPath = cleanPath(citizenRootConvar);
const fxServerPath = cleanPath(citizenRootConvar as string);

//Setting data path
let dataPath;
Expand Down
73 changes: 44 additions & 29 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
- [x] spawn
- [x] fix
- [x] delete
- [x] boost (FIXME: doesn't work, disable button)
- [x] boost (doesn't work, disable button)
- [x] Heal
- [x] self
- [x] everyone
- [x] Announcements
- [x] reset world area (FIXME: doesn't work, disable button)
- [x] reset world area (doesn't work, disable button)
- [x] player ids
- [x] logger (death reasons, explosions, etc)

Expand Down Expand Up @@ -94,37 +94,52 @@
- must start tracking the search duration
- [ ] maybe add some debug logging to `AdminVault.checkAdminsFile()`, to find out why so many people are having issues with their logins

=======================================================================
> FIXME: criar volume local bindado em /fxserver
docker run \
-p 40121:40120 \
-p 30121:30120 -p 30121:30120/udp \
--name fxstest \
ubuntu

docker exec -it fxstest bash
apt update
apt install wget xz-utils nano
apt install iputils-ping bind9-host mycli

mycli -u root -h 172.17.0.2

cfxk_1VMO47fvNuVJ8OkTrrCKK_2SkUUo
=======================================================================

"9:0000000000000000000000000000000000000000000000000000000000000001",
"9:0000000000000000000000000000000000000000000000000000000000000002",
"9:0000000000000000000000000000000000000000000000000000000000000003",
"9:0000000000000000000000000000000000000000000000000000000000000004",
"9:0000000000000000000000000000000000000000000000000000000000000005",
"9:0000000000000000000000000000000000000000000000000000000000000006"

--DEBUG
RegisterCommand('go', function()
Wait(2500)
gameSpawnReqHandler('p_c_horse_01')
-- gameSpawnReqHandler('a_c_horse_morgan_bay')
-- gameSpawnReqHandler('cart01')
end)
RegisterCommand('horse', function()
gameSpawnReqHandler('p_c_horse_01')
end)
RegisterCommand('cart', function()
gameSpawnReqHandler('cart01')
end)


SetMinimapHideFow(true)

return TaskLeaveAnyVehicle(ped, 0, 16)
return IsPedOnMount(ped)
-- redm: 1 if in horse, false if not, false if in carriage
-- fivem: xxx if in horse, false if not, false if in car
//FiveM
[
'2:5208e33d0101f1321f70144a7240803091e937c1d8706b501fd29a1ae483bfa3',
'3:ad900a3e544fe041035e4b0bc3220d2845dea24db8ccb4b0871c03651db3243f',
'5:8a566bae5fd25977740579ec51921b0a9877908b0ce271eb8bead7a73237349c',
'4:1bcd628567da10a439612f00cabd12f31b798f18d6f082b3314e1a8671bdbe29',
'4:0c03d88eafe46ba5dfaa063af0e5ea7f9f25c28c4c1428deb3393f80034d9753',
'4:35fe4c4c2369a44b16158c92021949d8334ab62500aa8729144c43278455250e'
]

return IsPedOnVehicle(ped)
-- redm: false if in horse, false if not, 1 if in carriage
-- fivem: xxx if in horse, false if not, false if in car
//RedM
[
'2:5208e33d0101f1321f70144a7240803091e937c1d8706b501fd29a1ae483bfa3',
'3:ad900a3e544fe041035e4b0bc3220d2845dea24db8ccb4b0871c03651db3243f',
'5:8a566bae5fd25977740579ec51921b0a9877908b0ce271eb8bead7a73237349c',
'4:0c67db88d06d10450ca5e1ecd797f121effaeb41fdf2f0d7eb4cef228bcc4258',
'4:0c03d88eafe46ba5dfaa063af0e5ea7f9f25c28c4c1428deb3393f80034d9753',
'4:bb030b94d17fa29f4feef12a6413965677078046c47e6d852cbb0c696718a9c7'
]

=======================================================================


function convertHrtime(hrtime) {
Expand All @@ -151,7 +166,7 @@ console.log(`${duration}ns`);
console.dir(convertHrtime(duration));



=======================================================================

(function() {
var s = document.createElement('script');
Expand All @@ -160,7 +175,7 @@ console.dir(convertHrtime(duration));
})()


cache static files
=======================================================================


## Optional
Expand All @@ -185,7 +200,7 @@ ScanResourceRoot('C:/whatever/resources/', data => {




=======================================================================



Expand Down
41 changes: 41 additions & 0 deletions scripts/typecheck-formatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env node
// npx tsc -p core/tsconfig.json --noEmit | ./scripts/typecheck-formatter.js

import chalk from 'chalk';

const filterOut = [
`Cannot find name 'globals'.`,
`Property 'body' does not exist on type 'Request'.`,
`has not been built from source file`,
];

let rawInput = '';
process.stdin.on('data', (data) => {
rawInput += data.toString('utf8');
});
process.stdin.on('end', () => {
processInput(rawInput.trim());
});


function processInput(rawInput) {
let errorCount = 0;
const allLines = rawInput.split('\n');
const filtered = allLines
.filter(errorLine => errorLine.includes('error TS'))
.filter(errorLine => !filterOut.some(filter => errorLine.includes(filter)));
for (const errorLine of filtered) {
// console.log(errorLine);
const [file, tsError, desc] = errorLine.split(': ', 3);

if (tsError) {
errorCount++;
console.log(chalk.yellow(file));
console.log(`\t${chalk.red(desc)}`);
} else {
console.log(`\t${chalk.red(errorLine)}`);
}
}
console.log('===========================');
console.log('errorCount', errorCount);
}

0 comments on commit 5794f89

Please sign in to comment.