From b6052e5669ac21368635a670fe8e06e7e6c71f07 Mon Sep 17 00:00:00 2001 From: Eduard Marbach Date: Sat, 2 Nov 2024 10:29:30 +0100 Subject: [PATCH] refactor: move index.ts to src --- Dockerfile | 2 +- esbuild.ts | 2 +- package.json | 2 +- index.ts => src/index.ts | 33 +++++++++++++-------------------- src/quality-definitions.ts | 11 +++-------- tsconfig.json | 14 +++++++++++++- 6 files changed, 32 insertions(+), 32 deletions(-) rename index.ts => src/index.ts (93%) diff --git a/Dockerfile b/Dockerfile index a7085d4..10f20ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfi FROM base AS builder COPY src src/ -COPY index.ts esbuild.ts ./ +COPY esbuild.ts ./ RUN pnpm run build diff --git a/esbuild.ts b/esbuild.ts index c656a86..54c7e47 100644 --- a/esbuild.ts +++ b/esbuild.ts @@ -4,7 +4,7 @@ const externalizedModules = {}; await esbuild.build({ //inject: ["cjs-shim.ts"], - entryPoints: ["index.ts"], + entryPoints: ["./src/index.ts"], bundle: true, sourcemap: "inline", platform: "node", diff --git a/package.json b/package.json index d52aeb1..819356d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "coverage": "vitest run --coverage", "generateApi": "tsx generate-api.ts && prettier src/__generated__ --write", "lint": "prettier . --check", - "start": "tsx index.ts", + "start": "tsx src/index.ts", "test": "vitest", "typecheck": "tsc --noEmit" }, diff --git a/index.ts b/src/index.ts similarity index 93% rename from index.ts rename to src/index.ts index f0b0127..c4ecc1d 100644 --- a/index.ts +++ b/src/index.ts @@ -1,26 +1,19 @@ import "dotenv/config"; import fs from "node:fs"; -import { MergedCustomFormatResource } from "./src/__generated__/mergedTypes"; -import { configureRadarrApi, configureSonarrApi, getArrApi, unsetApi } from "./src/api"; -import { getConfig, validateConfig } from "./src/config"; -import { - calculateCFsToManage, - loadCFFromConfig, - loadLocalCfs, - loadServerCustomFormats, - manageCf, - mergeCfSources, -} from "./src/custom-formats"; -import { logHeading, logger } from "./src/logger"; -import { calculateQualityDefinitionDiff, loadQualityDefinitionFromServer } from "./src/quality-definitions"; +import { MergedCustomFormatResource } from "./__generated__/mergedTypes"; +import { configureRadarrApi, configureSonarrApi, getArrApi, unsetApi } from "./api"; +import { getConfig, validateConfig } from "./config"; +import { calculateCFsToManage, loadCFFromConfig, loadLocalCfs, loadServerCustomFormats, manageCf, mergeCfSources } from "./custom-formats"; +import { logHeading, logger } from "./logger"; +import { calculateQualityDefinitionDiff, loadQualityDefinitionFromServer } from "./quality-definitions"; import { calculateQualityProfilesDiff, filterInvalidQualityProfiles, loadQualityProfilesFromServer, mapQualityProfiles, -} from "./src/quality-profiles"; -import { cloneRecyclarrTemplateRepo, loadRecyclarrTemplates } from "./src/recyclarr-importer"; +} from "./quality-profiles"; +import { cloneRecyclarrTemplateRepo, loadRecyclarrTemplates } from "./recyclarr-importer"; import { cloneTrashRepo, loadQPFromTrash, @@ -28,11 +21,11 @@ import { loadSonarrTrashCFs, transformTrashQPCFs, transformTrashQPToTemplate, -} from "./src/trash-guide"; -import { ArrType, CFProcessing, MappedMergedTemplates } from "./src/types/common.types"; -import { ConfigQualityProfile, InputConfigArrInstance, InputConfigIncludeItem, MergedConfigInstance } from "./src/types/config.types"; -import { TrashQualityDefintion } from "./src/types/trashguide.types"; -import { DEBUG_CREATE_FILES, IS_DRY_RUN } from "./src/util"; +} from "./trash-guide"; +import { ArrType, CFProcessing, MappedMergedTemplates } from "./types/common.types"; +import { ConfigQualityProfile, InputConfigArrInstance, InputConfigIncludeItem, MergedConfigInstance } from "./types/config.types"; +import { TrashQualityDefintion } from "./types/trashguide.types"; +import { DEBUG_CREATE_FILES, IS_DRY_RUN } from "./util"; /** * Load data from trash, recyclarr, custom configs and merge. diff --git a/src/quality-definitions.ts b/src/quality-definitions.ts index 2a9f389..71ac641 100644 --- a/src/quality-definitions.ts +++ b/src/quality-definitions.ts @@ -1,7 +1,6 @@ import path from "node:path"; import { MergedQualityDefinitionResource } from "./__generated__/mergedTypes"; import { getArrApi } from "./api"; -import { logger } from "./logger"; import { TrashQualityDefintion, TrashQualityDefintionQuality } from "./types/trashguide.types"; import { IS_LOCAL_SAMPLE_MODE, loadJsonFile } from "./util"; @@ -29,18 +28,14 @@ export const calculateQualityDefinitionDiff = (serverQDs: MergedQualityDefinitio if (element) { const changes: string[] = []; - if (!element.maxSize) { - logger.info(`No maxSize defined: ${element.title}`); - } - if (element.minSize !== tq.min) { - changes.push(`MinSize diff: ${element.minSize} - ${tq.min}`); + changes.push(`MinSize diff: Server ${element.minSize} - Config ${tq.min}`); } if (element.maxSize !== tq.max) { - changes.push(`MaxSize diff: ${element.maxSize} - ${tq.max}`); + changes.push(`MaxSize diff: Server ${element.maxSize} - Config ${tq.max}`); } if (element.preferredSize !== tq.preferred) { - changes.push(`PreferredSize diff: ${element.preferredSize} - ${tq.preferred}`); + changes.push(`PreferredSize diff: Server ${element.preferredSize} - Config ${tq.preferred}`); } if (changes.length > 0) { diff --git a/tsconfig.json b/tsconfig.json index b401ca3..085d0ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,23 @@ "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "allowJs": true, + "baseUrl": ".", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "lib": ["DOM", "DOM.Iterable", "ESNext"], "module": "ESNext", "moduleResolution": "Bundler", + "noUncheckedIndexedAccess": true, + "paths": { + "~/*": ["./src/*"] + }, + "resolveJsonModule": true, "skipLibCheck": true, "strict": true, + "strictNullChecks": true, "target": "ESNext" }, - "exclude": ["./dist"] + "exclude": ["./dist"], + "include": ["**/*.ts", "**/*.tsx"] }