diff --git a/Dockerfile b/Dockerfile index a22625a0..d23f0aa7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ RUN corepack enable pnpm RUN CI=true pnpm i # Compile new dist file RUN npx tsc-transpile-only +# Compile library module so it is readable by src +RUN pnpm run lib-compile # Remove non-dist files RUN rm -rf src/ @types/ .env.production # Start the process within the container diff --git a/package.json b/package.json index 0b3467cd..578d4fa1 100644 --- a/package.json +++ b/package.json @@ -72,10 +72,11 @@ }, "scripts": { "preinstall": "npx only-allow pnpm", - "compile": "rm -rf dist/ && tsc", + "compile": "rm -rf dist/ && tsc && pnpm run lib-compile", "start": "node --max-old-space-size=4096 dist/src/app", "pm2": "pm2 start dist/src/app.js --name 'DEL'", "css-compile": "sh ./scripts/css_build.sh", + "lib-compile": "mkdir ./dist/node_modules/ && cp -R ./node_modules/lib-comparison/ ./dist/node_modules/lib-comparison/ && tsc ./dist/node_modules/lib-comparison/libs.ts", "snyk-protect": "snyk-protect", "prepare": "pnpm run snyk-protect", "pretty": "npx prettier --write src/" diff --git a/src/setup.ts b/src/setup.ts index fe6170df..378e3763 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -17,18 +17,27 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -import { libs } from "lib-comparison/libs"; +import { libs } from "../node_modules/lib-comparison/libs.js"; + +function cleanLibName(lib: string) { + if (lib.includes(" 🍴🪦")) return lib.replace(" 🍴🪦", ""); + if (lib.includes(" 🍴")) return lib.replace(" 🍴", ""); + if (lib.includes(" 🪦")) return lib.replace(" 🪦", ""); + if (lib.includes("🪦")) return lib.replace("🪦", ""); + return lib; +} async function setup() { console.log("Setup: Updating libraries..."); + await global.db.collection("libraries").drop(); for (const lib of libs) { await global.db .collection("libraries") .updateOne( - { _id: lib.name }, + { _id: cleanLibName(lib.name) }, { $set: { - _id: lib.name, + _id: cleanLibName(lib.name), language: lib.language, link: lib.url }