From 18646b9dc6a37b7ee2594cd6d5352930461e4f9f Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Thu, 21 Sep 2023 20:43:43 +0200 Subject: [PATCH] config: fix imports not working correctly this patch moves the rootDir of the typescript project up a directory this moves all content in the dist directory inside the new src directory I couldn't find other way --- Dockerfile | 2 +- package.json | 6 +++--- src/index.ts | 12 ++++++++++-- tsconfig.json | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index d288a6a..4b9f015 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,4 +15,4 @@ COPY src ./src RUN npx tsc # Run the app -CMD ["node", "dist/index.js"] +CMD ["node", "dist/src/index.js"] diff --git a/package.json b/package.json index 27b96fb..16a5e24 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,11 @@ "name": "gptcord", "version": "0.1.0", "description": "", - "main": "./dist/index.js", + "main": "./dist/src/index.js", "scripts": { - "start": "tsc && node dist/index.js", + "start": "tsc && node dist/src/index.js", "test": "echo \"Error: no test specified\" && exit 1", - "publishCommands": "tsc && node dist/scripts/pushCommands.js" + "publishCommands": "tsc && node dist/src/scripts/pushCommands.js" }, "author": "Wroclaw", "license": "MIT", diff --git a/src/index.ts b/src/index.ts index ac2a2a7..66a2ceb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,9 +23,17 @@ function getConfig() { ["./config.ts"], {outDir: "./dist"} ); - program.emit(program.getSourceFile("./config.ts")); + + program.getSourceFiles() + .filter(e => { + if (!e.fileName.match(`^${process.cwd()}`)) return true; + if (e.fileName.match(`${process.cwd()}/node_modules`)) return false; + if (e.fileName.match(`${process.cwd()}/src/`)) return false; + return true; + }) + .forEach(e => program.emit(e)); // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access - fileConfig = require("./config").default as IConfig; + fileConfig = require("../config").default as IConfig; } catch (e) { //FIXME: make errors more descriptive to the enduser console.log(e); diff --git a/tsconfig.json b/tsconfig.json index 66df360..77c5666 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "module": "CommonJS", "sourceMap": true, "outDir": "./dist/", - "rootDir": "./src/", + "rootDir": "./", "strict": true, "moduleResolution": "node", "esModuleInterop": true,