mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
fix: lint
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { existsSync } from 'fs';
|
||||||
import { readFile, writeFile } from 'fs/promises';
|
import { readFile, writeFile } from 'fs/promises';
|
||||||
import { basename, resolve } from 'path';
|
import { basename, resolve } from 'path';
|
||||||
|
|
||||||
@@ -8,7 +9,6 @@ import { FileModification } from '@app/unraid-api/unraid-file-modifier/file-modi
|
|||||||
import DefaultPageLayoutModification from '@app/unraid-api/unraid-file-modifier/modifications/default-page-layout.modification';
|
import DefaultPageLayoutModification from '@app/unraid-api/unraid-file-modifier/modifications/default-page-layout.modification';
|
||||||
import NotificationsPageModification from '@app/unraid-api/unraid-file-modifier/modifications/notifications-page.modification';
|
import NotificationsPageModification from '@app/unraid-api/unraid-file-modifier/modifications/notifications-page.modification';
|
||||||
import SSOFileModification from '@app/unraid-api/unraid-file-modifier/modifications/sso.modification';
|
import SSOFileModification from '@app/unraid-api/unraid-file-modifier/modifications/sso.modification';
|
||||||
import { existsSync } from 'fs';
|
|
||||||
|
|
||||||
interface ModificationTestCase {
|
interface ModificationTestCase {
|
||||||
ModificationClass: new (...args: ConstructorParameters<typeof FileModification>) => FileModification;
|
ModificationClass: new (...args: ConstructorParameters<typeof FileModification>) => FileModification;
|
||||||
@@ -50,10 +50,10 @@ async function testModification(testCase: ModificationTestCase) {
|
|||||||
|
|
||||||
const logger = new Logger();
|
const logger = new Logger();
|
||||||
const patcher = await new testCase.ModificationClass(logger);
|
const patcher = await new testCase.ModificationClass(logger);
|
||||||
// @ts-ignore - Ignore for testing purposes
|
// @ts-expect-error - Ignore for testing purposes
|
||||||
patcher.filePath = path;
|
patcher.filePath = path;
|
||||||
|
|
||||||
// @ts-ignore - Ignore for testing purposes
|
// @ts-expect-error - Ignore for testing purposes
|
||||||
const patch = await patcher.generatePatch();
|
const patch = await patcher.generatePatch();
|
||||||
|
|
||||||
// Test patch matches snapshot
|
// Test patch matches snapshot
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import {
|
|||||||
|
|
||||||
export default class DefaultPageLayoutModification extends FileModification {
|
export default class DefaultPageLayoutModification extends FileModification {
|
||||||
id: string = 'default-page-layout';
|
id: string = 'default-page-layout';
|
||||||
public readonly filePath: string =
|
public readonly filePath: string = '/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php';
|
||||||
'/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php';
|
|
||||||
|
|
||||||
private addToaster(source: string): string {
|
private addToaster(source: string): string {
|
||||||
if (source.includes('unraid-toaster')) {
|
if (source.includes('unraid-toaster')) {
|
||||||
@@ -45,7 +44,6 @@ export default class DefaultPageLayoutModification extends FileModification {
|
|||||||
protected async generatePatch(): Promise<string> {
|
protected async generatePatch(): Promise<string> {
|
||||||
const fileContent = await readFile(this.filePath, 'utf-8');
|
const fileContent = await readFile(this.filePath, 'utf-8');
|
||||||
|
|
||||||
|
|
||||||
const newContent = this.applyToSource(fileContent);
|
const newContent = this.applyToSource(fileContent);
|
||||||
|
|
||||||
const patch = createPatch(this.filePath, fileContent, newContent, undefined, undefined, {
|
const patch = createPatch(this.filePath, fileContent, newContent, undefined, undefined, {
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import type { Logger } from '@nestjs/common';
|
import type { Logger } from '@nestjs/common';
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
|
|
||||||
import { createPatch } from 'diff';
|
import { createPatch } from 'diff';
|
||||||
import { FileModification, ShouldApplyWithReason } from '@app/unraid-api/unraid-file-modifier/file-modification';
|
|
||||||
|
import {
|
||||||
|
FileModification,
|
||||||
|
ShouldApplyWithReason,
|
||||||
|
} from '@app/unraid-api/unraid-file-modifier/file-modification';
|
||||||
|
|
||||||
export default class SSOFileModification extends FileModification {
|
export default class SSOFileModification extends FileModification {
|
||||||
id: string = 'sso';
|
id: string = 'sso';
|
||||||
@@ -43,7 +48,7 @@ function verifyUsernamePasswordAndSSO(string $username, string $password): bool
|
|||||||
|
|
||||||
// Read the file content
|
// Read the file content
|
||||||
const originalContent = await readFile(this.filePath, 'utf-8');
|
const originalContent = await readFile(this.filePath, 'utf-8');
|
||||||
|
|
||||||
// Create modified content
|
// Create modified content
|
||||||
let newContent = originalContent;
|
let newContent = originalContent;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user