Skip to content

Commit 7185f6c

Browse files
committed
wip: small changes
1 parent 0c3ddff commit 7185f6c

17 files changed

Lines changed: 51 additions & 51 deletions

File tree

core/boot/checkPreRelease.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import humanizeDuration, { Unit } from 'humanize-duration';
2-
import chalk from 'chalk';
31
import consoleFactory from '@lib/console';
42
import fatalError from '@lib/fatalError';
5-
import { msToDuration } from '@lib/misc';
3+
import { chalkInversePad, msToDuration } from '@lib/misc';
64
const console = consoleFactory('ATTENTION');
75

86

@@ -16,11 +14,10 @@ const expiredError = [
1614

1715
const printExpirationBanner = (timeUntilExpiration: number) => {
1816
const timeLeft = msToDuration(timeUntilExpiration)
19-
const timeLeftStyled = chalk.inverse(` ${timeLeft} `);
2017
console.error('This is a pre-release version of txAdmin!');
2118
console.error('This build is meant to be used by txAdmin beta testers.');
2219
console.error('txAdmin will automatically shut down when this pre-release expires.');
23-
console.error(`Time until expiration: ${timeLeftStyled}.`);
20+
console.error(`Time until expiration: ${chalkInversePad(timeLeft)}.`);
2421
console.error('For more information: https://discord.gg/txAdmin.');
2522
}
2623

core/boot/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const modulename = 'Setup';
22
import path from 'node:path';
33
import fs from 'node:fs';
44

5-
import chalk from 'chalk';
65
import consoleFactory from '@lib/console';
76
import fatalError from '@lib/fatalError';
87
import { txEnv } from '@core/globalData';
98
import ConfigStore from '@modules/ConfigStore';
9+
import { chalkInversePad } from '@lib/misc';
1010
const console = consoleFactory(modulename);
1111

1212

@@ -63,7 +63,7 @@ export const setupProfile = () => {
6363
const batFolder = path.resolve(txEnv.fxServerPath, '..');
6464
const batPath = path.join(batFolder, batFilename);
6565
fs.writeFileSync(batPath, batLines.join('\r\n'));
66-
console.ok(`You can use ${chalk.inverse(batPath)} to start this profile.`);
66+
console.ok(`You can use ${chalkInversePad(batPath)} to start this profile.`);
6767
} catch (error) {
6868
console.warn(`Failed to create '${batFilename}' with error:`);
6969
console.dir(error);

core/boot/startReadyWatcher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import getOsDistro from '@lib/host/getOsDistro.js';
99
import { convars, txDevEnv, txEnv } from '@core/globalData';
1010
import consoleFactory from '@lib/console';
1111
import { addLocalIpAddress } from '@lib/host/isIpAddressLocal';
12+
import { chalkInversePad } from '@lib/misc';
1213
const console = consoleFactory();
1314

1415

@@ -171,7 +172,7 @@ export const startReadyWatcher = async (cb: () => void) => {
171172
} satisfies BoxenOptions;
172173
const boxLines = [
173174
'All ready! Please access:',
174-
...bannerUrls.map((url) => chalk.inverse(` ${url} `)),
175+
...bannerUrls.map(chalkInversePad),
175176
...adminPinLines,
176177
];
177178
console.multiline(boxen(boxLines.join('\n'), boxOptions), chalk.bgGreen);

core/lib/misc.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import chalk from 'chalk';
12
import dateFormat from 'dateformat';
23
import humanizeDuration, { HumanizerOptions } from 'humanize-duration';
34
import { DeepReadonly } from 'utility-types';
@@ -259,3 +260,9 @@ export const deepFreeze = <T extends Record<string, any>>(obj: T) => {
259260
//FIXME: using DeepReadonly<T> will cause ts errors in ConfigStore
260261
// return obj as DeepReadonly<T>;
261262
};
263+
264+
265+
/**
266+
* Returns a chalk.inverse of a string with a 1ch padding
267+
*/
268+
export const chalkInversePad = (str: string) => chalk.inverse(` ${str} `);

core/modules/AdminStore/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { convars, txEnv } from '@core/globalData';
77
import CfxProvider from './providers/CitizenFX.js';
88
import { createHash } from 'node:crypto';
99
import consoleFactory from '@lib/console.js';
10-
import chalk from 'chalk';
1110
import fatalError from '@lib/fatalError.js';
11+
import { chalkInversePad } from '@lib/misc.js';
1212
const console = consoleFactory(modulename);
1313

1414
//NOTE: The way I'm doing versioning right now is horrible but for now it's the best I can do
@@ -656,7 +656,7 @@ export default class AdminStore {
656656
return true;
657657
} else {
658658
if (printPin) {
659-
console.warn('Use this PIN to add a new master account: ' + chalk.inverse(` ${this.addMasterPin} `));
659+
console.warn('Use this PIN to add a new master account: ' + chalkInversePad(this.addMasterPin));
660660
}
661661
return false;
662662
}

core/modules/ConfigStore/configMigrations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import fatalError from '@lib/fatalError';
77
import { CONFIG_VERSION } from './index'; //FIXME: circular_dependency
88
import { migrateOldConfig } from './schema/oldConfig';
99
import consoleFactory from '@lib/console';
10+
import { chalkInversePad } from '@lib/misc';
1011
const console = consoleFactory(modulename);
1112

1213

@@ -19,7 +20,7 @@ const saveBackupFile = (version: number) => {
1920
`${txEnv.profilePath}/config.json`,
2021
`${txEnv.profilePath}/${bkpFileName}`,
2122
);
22-
console.log(`A backup of your config file was saved on: ${bkpFileName}`);
23+
console.log(`A backup of your config file was saved as: ${chalkInversePad(bkpFileName)}`);
2324
}
2425

2526

core/modules/Logger/handlers/admin.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const modulename = 'Logger:Admin';
22
import fsp from 'node:fs/promises';
33
import path from 'node:path';
4-
import chalk from 'chalk';
54
import { getBootDivider } from '../loggerUtils';
65
import consoleFactory from '@lib/console';
76
import { LoggerBase } from '../LoggerBase';
8-
import { getTimeHms } from '@lib/misc';
7+
import { chalkInversePad, getTimeHms } from '@lib/misc';
98
const console = consoleFactory(modulename);
109

1110

@@ -55,7 +54,7 @@ export default class AdminLogger extends LoggerBase {
5554
let saveMsg;
5655
if (type === 'command') {
5756
saveMsg = `[${author}] executed "${action}"`;
58-
console.log(`${author} executed ` + chalk.inverse(' ' + action + ' '));
57+
console.log(`${author} executed ` + chalkInversePad(action));
5958
} else {
6059
saveMsg = `[${author}] ${action}`;
6160
console.log(saveMsg);

core/modules/WebServer/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,6 @@ export default class WebServer {
253253
*/
254254
resetToken() {
255255
this.luaComToken = nanoid();
256-
console.verbose.log('Resetting luaComToken.');
256+
console.verbose.debug('Resetting luaComToken.');
257257
}
258258
};

core/routes/fxserver/schedule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default async function FXServerSchedule(ctx: AuthedCtx) {
2929
});
3030
}
3131

32-
if (action == 'setNextTempSchedule') {
32+
if (action === 'setNextTempSchedule') {
3333
try {
3434
txCore.fxScheduler.setNextTempSchedule(parameter);
3535
ctx.admin.logAction(`Scheduling server restart at ${parameter}`);
@@ -44,7 +44,7 @@ export default async function FXServerSchedule(ctx: AuthedCtx) {
4444
});
4545
}
4646

47-
} else if (action == 'setNextSkip') {
47+
} else if (action === 'setNextSkip') {
4848
try {
4949
txCore.fxScheduler.setNextSkip(parameter, ctx.admin.name);
5050
const logAct = parameter ? 'Cancelling' : 'Re-enabling';

docs/dev-notes.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Legend:
2525
- [ ] the console lines are shorter on first full render (ctrl+f5) and on f5 it fixes itself
2626
- didn't happen in v7.2.2, not sure about v7.3.2
2727
- doesn't seem to be neither fontSize nor lineHeight
28+
- NOTE: this might solve itself with the WebGL renderer update, so try that first
2829

2930
## Refactor + DX
3031
- [x] deprecate fxRunner.srvCmd
@@ -103,8 +104,6 @@ Legend:
103104
- [x] disable the "view changelog" button, or write the modal code
104105
- [x] write dev notes on the config system (README.md in the panel settings and core configstore?)
105106
- [x] Full FXRunner rewrite
106-
- [ ] implement `cleanFullPath.ts` in settings save ui & api for comparison consistency
107-
- [ ] add it to `setup/save.js -> handleValidateLocalDataFolder()` as well
108107

109108
## Other stuff
110109
- [x] new env vars
@@ -117,6 +116,8 @@ Legend:
117116
- https://nodejs.org/docs/latest-v16.x/api/fs.html#fspromiseslinkexistingpath-newpath
118117
- https://nodejs.org/docs/latest-v16.x/api/fs.html#fspromisessymlinktarget-path-type
119118
- [!] check txAdmin-private
119+
- [ ] implement `cleanFullPath.ts` in settings save ui & api for comparison consistency
120+
- [ ] add it to `setup/save.js -> handleValidateLocalDataFolder()` as well
120121

121122

122123

@@ -139,7 +140,7 @@ Legend:
139140
- 360x510 menor razoável
140141
- 390x670 mais comum
141142

142-
143+
- [ ] use os.networkInterfaces()?
143144

144145

145146
## Chores + boring stuff

0 commit comments

Comments
 (0)