From 2d3892deb828a815b5d66ee46c2da5fb223d3a7f Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Sun, 19 Jan 2025 23:14:03 -0500 Subject: [PATCH] feat: remove unused fields --- api/src/store/modules/config.ts | 2 +- api/src/unraid-api/cli/cli.module.ts | 4 ++- api/src/unraid-api/cli/config.command.ts | 25 +++++++++++++++++++ api/src/unraid-api/cli/restart.command.ts | 2 +- .../unraid-api/cli/validate-token.command.ts | 1 + 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 api/src/unraid-api/cli/config.command.ts diff --git a/api/src/store/modules/config.ts b/api/src/store/modules/config.ts index 9fcef11c0..c05991bc1 100644 --- a/api/src/store/modules/config.ts +++ b/api/src/store/modules/config.ts @@ -270,7 +270,7 @@ export const config = createSlice({ }); builder.addCase(setGraphqlConnectionStatus, (state, action) => { - state.connectionStatus.minigraph = action.payload.status; + state.connectionStatus.minigraph = action.payload.status; }); builder.addCase(setupRemoteAccessThunk.fulfilled, (state, action) => { diff --git a/api/src/unraid-api/cli/cli.module.ts b/api/src/unraid-api/cli/cli.module.ts index bd1809391..0f61d082e 100644 --- a/api/src/unraid-api/cli/cli.module.ts +++ b/api/src/unraid-api/cli/cli.module.ts @@ -11,6 +11,7 @@ import { VersionCommand } from '@app/unraid-api/cli/version.command'; import { StatusCommand } from '@app/unraid-api/cli/status.command'; import { ValidateTokenCommand } from '@app/unraid-api/cli/validate-token.command'; import { LogsCommand } from '@app/unraid-api/cli/logs.command'; +import { ConfigCommand } from '@app/unraid-api/cli/config.command'; @Module({ providers: [ @@ -24,7 +25,8 @@ import { LogsCommand } from '@app/unraid-api/cli/logs.command'; VersionCommand, StatusCommand, ValidateTokenCommand, - LogsCommand + LogsCommand, + ConfigCommand ], }) export class CliModule {} diff --git a/api/src/unraid-api/cli/config.command.ts b/api/src/unraid-api/cli/config.command.ts new file mode 100644 index 000000000..d18795e62 --- /dev/null +++ b/api/src/unraid-api/cli/config.command.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@nestjs/common'; +import { readFile } from 'fs/promises'; + +import { Command, CommandRunner } from 'nest-commander'; + +import { getters } from '@app/store/index'; +import { LogService } from '@app/unraid-api/cli/log.service'; + +@Injectable() +@Command({ + name: 'config', + description: 'Display current configuration values', +}) +export class ConfigCommand extends CommandRunner { + constructor(private readonly logger: LogService) { + super(); + } + + async run(): Promise { + this.logger.log('\nDisk Configuration:'); + const diskConfig = await readFile(getters.paths()['myservers-config'], 'utf8'); + this.logger.log(diskConfig); + process.exit(0); + } +} diff --git a/api/src/unraid-api/cli/restart.command.ts b/api/src/unraid-api/cli/restart.command.ts index ca7e7b31c..3e5e96921 100644 --- a/api/src/unraid-api/cli/restart.command.ts +++ b/api/src/unraid-api/cli/restart.command.ts @@ -14,7 +14,7 @@ export class RestartCommand extends CommandRunner { } async run(_): Promise { - const { stderr, stdout } = await execa(PM2_PATH, ['restart', ECOSYSTEM_PATH]); + const { stderr, stdout } = await execa(PM2_PATH, ['restart', ECOSYSTEM_PATH, '--update-env']); if (stderr) { this.logger.error(stderr); process.exit(1); diff --git a/api/src/unraid-api/cli/validate-token.command.ts b/api/src/unraid-api/cli/validate-token.command.ts index 0b0bc663e..cf5f25153 100644 --- a/api/src/unraid-api/cli/validate-token.command.ts +++ b/api/src/unraid-api/cli/validate-token.command.ts @@ -79,6 +79,7 @@ export class ValidateTokenCommand extends CommandRunner { const possibleUserIds = configFile.remote.ssoSubIds.split(','); if (possibleUserIds.includes(username)) { this.logger.info(JSON.stringify({ error: null, valid: true, username })); + process.exit(0); } else { this.createErrorAndExit('Username on token does not match'); }