From 4c811c160b74879fe478f3dca2038c0036dfb66e Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 16 Nov 2024 01:35:15 +0100 Subject: [PATCH] restructure --- producer/package.json | 2 +- scripts/build.js | 12 ++++++++++-- shared/tsconfig.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/producer/package.json b/producer/package.json index 48e6317..4ac5e9c 100644 --- a/producer/package.json +++ b/producer/package.json @@ -17,7 +17,7 @@ "dev": "node scripts/start_dev.js", "compile": "tsc", "build_project": "node ../scripts/build.js", - "build": "npm run compile && npm run build", + "build": "npm run compile && npm run build_project", "docker-build": "docker build -t litlyx-producer -f Dockerfile ../", "docker-inspect": "docker run -it litlyx-producer sh" }, diff --git a/scripts/build.js b/scripts/build.js index 642a134..48ebe53 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -4,7 +4,7 @@ const { globSync } = require('glob'); const fs = require('fs'); const path = require('path'); -const tsConfigPath = path.join(process.cwd(), 'tsconfig.json'); +const tsConfigPath = path.join(process.cwd(), '../tsconfig.json'); const tsconfigContent = fs.readFileSync(tsConfigPath, 'utf8'); const tsconfigObject = JSON.parse(tsconfigContent); @@ -12,17 +12,25 @@ const paths = tsconfigObject.compilerOptions.paths; const filesList = globSync('dist/**/*.js'); +console.log(`[BUILD] Building ${filesList.length} files`); + filesList.forEach(file => { + let raw = fs.readFileSync(file, 'utf8'); for (const path in paths) { const deep = (file.match(/\\|\//g) || []).length; const pathText = path.replace('*', ''); const toReplaceText = new RegExp(`"${pathText}(.*?)"`, 'g'); + try { - raw = raw.replace(toReplaceText, `"${new Array(deep - 2).fill('../').join('')}${paths[path][0].replace('*', '')}${'$1'}"`); + raw = raw.replace(toReplaceText, `"${new Array(deep - 2).fill('../').join('')}.${paths[path][0].replace('*', '')}${'$1'}"`); } catch (ex) { console.log({ deep, pathText, toReplaceText, path }) } } + fs.writeFileSync(file, raw); + }); + +console.log(`[BUILD] Done`); \ No newline at end of file diff --git a/shared/tsconfig.json b/shared/tsconfig.json index 291edf3..bf396cc 100644 --- a/shared/tsconfig.json +++ b/shared/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "module": "NodeNext", "target": "ESNext",