diff --git a/Dockerfile b/Dockerfile index 8e12849..62cb055 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,13 @@ # https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md -FROM node:20.16.0-slim AS base +FROM node:22.5.1-slim AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN apt-get update && apt-get install -y \ git \ && rm -rf /var/lib/apt/lists/* \ - && corepack enable && corepack prepare pnpm@9 --activate + && corepack enable \ + && corepack prepare pnpm@9 --activate WORKDIR /app COPY package.json pnpm-lock.yaml /app/ @@ -14,9 +15,10 @@ FROM base AS prod-deps RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile FROM base +RUN corepack use pnpm@9 +COPY --from=prod-deps /app/node_modules /app/node_modules COPY index.ts /app/ COPY src/ /app/src/ -COPY --from=prod-deps /app/node_modules /app/node_modules ENV CONFIG_LOCATION=/app/config/config.yml ENV SECRETS_LOCATION=/app/config/secrets.yml diff --git a/index.ts b/index.ts index c166931..26cfb19 100644 --- a/index.ts +++ b/index.ts @@ -277,6 +277,7 @@ const run = async () => { if (IS_DRY_RUN) { logger.info("DryRun: Running in dry-run mode!"); } + const applicationConfig = getConfig(); await cloneRecyclarrTemplateRepo(); diff --git a/package.json b/package.json index ba8a21c..4fbfd01 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@playwright/test": "1.45.3", - "@types/node": "20.14.13", + "@types/node": "22.0.2", "@vitest/coverage-v8": "2.0.5", "prettier": "3.3.3", "typescript": "5.5.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b38ed1c..004bd70 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: '@infinite-debugger/swagger-to-ts': specifier: 0.1.0-alpha.124 - version: 0.1.0-alpha.124(@types/node@20.14.13)(crypto-js@4.2.0)(date-fns@3.6.0)(typescript@5.5.4) + version: 0.1.0-alpha.124(@types/node@22.0.2)(crypto-js@4.2.0)(date-fns@3.6.0)(typescript@5.5.4) axios: specifier: 1.7.2 version: 1.7.2 @@ -43,11 +43,11 @@ importers: specifier: 1.45.3 version: 1.45.3 '@types/node': - specifier: 20.14.13 - version: 20.14.13 + specifier: 22.0.2 + version: 22.0.2 '@vitest/coverage-v8': specifier: 2.0.5 - version: 2.0.5(vitest@2.0.5(@types/node@20.14.13)) + version: 2.0.5(vitest@2.0.5(@types/node@22.0.2)) prettier: specifier: 3.3.3 version: 3.3.3 @@ -56,7 +56,7 @@ importers: version: 5.5.4 vitest: specifier: 2.0.5 - version: 2.0.5(@types/node@20.14.13) + version: 2.0.5(@types/node@22.0.2) packages: @@ -584,6 +584,9 @@ packages: '@types/node@20.14.13': resolution: {integrity: sha512-+bHoGiZb8UiQ0+WEtmph2IWQCjIqg8MDZMAV+ppRRhUZnquF5mQkP/9vpSwJClEiSM/C7fZZExPzfU0vJTyp8w==} + '@types/node@22.0.2': + resolution: {integrity: sha512-yPL6DyFwY5PiMVEwymNeqUTKsDczQBJ/5T7W/46RwLU/VH+AA8aT5TZkvBviLKLbbm0hlfftEkGrNzfRk/fofQ==} + '@types/semver@7.5.8': resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} @@ -1756,6 +1759,9 @@ packages: undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + undici-types@6.11.1: + resolution: {integrity: sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==} + unicode-emoji-modifier-base@1.0.0: resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==} engines: {node: '>=4'} @@ -2118,7 +2124,7 @@ snapshots: date-fns: 3.6.0 lodash: 4.17.21 - '@infinite-debugger/swagger-to-ts@0.1.0-alpha.124(@types/node@20.14.13)(crypto-js@4.2.0)(date-fns@3.6.0)(typescript@5.5.4)': + '@infinite-debugger/swagger-to-ts@0.1.0-alpha.124(@types/node@22.0.2)(crypto-js@4.2.0)(date-fns@3.6.0)(typescript@5.5.4)': dependencies: '@infinite-debugger/rmk-js-extensions': 0.1.0-alpha.28 '@infinite-debugger/rmk-utils': 0.1.0-alpha.29(crypto-js@4.2.0)(date-fns@3.6.0)(lodash@4.17.21) @@ -2129,7 +2135,7 @@ snapshots: lodash: 4.17.21 pluralize: 8.0.0 prettier: 2.8.8 - ts-node: 10.9.2(@types/node@20.14.13)(typescript@5.5.4) + ts-node: 10.9.2(@types/node@22.0.2)(typescript@5.5.4) walk-sync: 3.0.0 zod: 3.22.4 transitivePeerDependencies: @@ -2269,6 +2275,10 @@ snapshots: dependencies: undici-types: 5.26.5 + '@types/node@22.0.2': + dependencies: + undici-types: 6.11.1 + '@types/semver@7.5.8': {} '@types/swagger-schema-official@2.0.25': {} @@ -2359,7 +2369,7 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitest/coverage-v8@2.0.5(vitest@2.0.5(@types/node@20.14.13))': + '@vitest/coverage-v8@2.0.5(vitest@2.0.5(@types/node@22.0.2))': dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 @@ -2373,7 +2383,7 @@ snapshots: std-env: 3.7.0 test-exclude: 7.0.1 tinyrainbow: 1.2.0 - vitest: 2.0.5(@types/node@20.14.13) + vitest: 2.0.5(@types/node@22.0.2) transitivePeerDependencies: - supports-color @@ -3491,14 +3501,14 @@ snapshots: tr46@0.0.3: {} - ts-node@10.9.2(@types/node@20.14.13)(typescript@5.5.4): + ts-node@10.9.2(@types/node@22.0.2)(typescript@5.5.4): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.9 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.14.13 + '@types/node': 22.0.2 acorn: 8.11.3 acorn-walk: 8.3.2 arg: 4.1.3 @@ -3533,6 +3543,8 @@ snapshots: undici-types@5.26.5: {} + undici-types@6.11.1: {} + unicode-emoji-modifier-base@1.0.0: {} universalify@2.0.1: {} @@ -3543,13 +3555,13 @@ snapshots: v8-compile-cache-lib@3.0.1: {} - vite-node@2.0.5(@types/node@20.14.13): + vite-node@2.0.5(@types/node@22.0.2): dependencies: cac: 6.7.14 debug: 4.3.5 pathe: 1.1.2 tinyrainbow: 1.2.0 - vite: 5.2.6(@types/node@20.14.13) + vite: 5.2.6(@types/node@22.0.2) transitivePeerDependencies: - '@types/node' - less @@ -3560,16 +3572,16 @@ snapshots: - supports-color - terser - vite@5.2.6(@types/node@20.14.13): + vite@5.2.6(@types/node@22.0.2): dependencies: esbuild: 0.20.2 postcss: 8.4.38 rollup: 4.13.1 optionalDependencies: - '@types/node': 20.14.13 + '@types/node': 22.0.2 fsevents: 2.3.3 - vitest@2.0.5(@types/node@20.14.13): + vitest@2.0.5(@types/node@22.0.2): dependencies: '@ampproject/remapping': 2.3.0 '@vitest/expect': 2.0.5 @@ -3587,11 +3599,11 @@ snapshots: tinybench: 2.8.0 tinypool: 1.0.0 tinyrainbow: 1.2.0 - vite: 5.2.6(@types/node@20.14.13) - vite-node: 2.0.5(@types/node@20.14.13) + vite: 5.2.6(@types/node@22.0.2) + vite-node: 2.0.5(@types/node@22.0.2) why-is-node-running: 2.3.0 optionalDependencies: - '@types/node': 20.14.13 + '@types/node': 22.0.2 transitivePeerDependencies: - less - lightningcss diff --git a/src/config.ts b/src/config.ts index a417c39..2284ec7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,6 @@ -import { readFileSync } from "fs"; +import { existsSync, readFileSync } from "fs"; import yaml from "yaml"; +import { logger } from "./logger"; import { YamlConfig } from "./types"; import { ROOT_PATH } from "./util"; @@ -24,6 +25,11 @@ export const getConfig = (): YamlConfig => { return config; } + if (!existsSync(CONFIG_LOCATION)) { + logger.error(`Config file in location "${CONFIG_LOCATION}" does not exists.`); + throw new Error("Config file not found."); + } + const file = readFileSync(CONFIG_LOCATION, "utf8"); config = yaml.parse(file, { customTags: [secretsTag] }) as YamlConfig; return config; @@ -34,6 +40,11 @@ export const getSecrets = () => { return secrets; } + if (!existsSync(SECRETS_LOCATION)) { + logger.error(`Secret file in location "${SECRETS_LOCATION}" does not exists.`); + throw new Error("Secret file not found."); + } + const file = readFileSync(SECRETS_LOCATION, "utf8"); config = yaml.parse(file); return config;