From d18972b9aa02c4075f6cad2306af8ec32aaa809f Mon Sep 17 00:00:00 2001 From: Fallenbagel <98979876+Fallenbagel@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:07:25 +0500 Subject: [PATCH] build(postinstall): postinstall script to downgrade typeorm on windows (#836) * build(postinstall): postinstall script to downgrade typeorm on windows This is a temporary fix for windows baremetal users until we fix #478 re #478 * fix: use win32 as explained in nodejs docs --- README.md | 1 - package.json | 1 + postinstall-win.js | 13 +++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 postinstall-win.js diff --git a/README.md b/README.md index 6e6cc8e34..bab2978c9 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ Pre-requisites: npm i -g win-node-env set CYPRESS_INSTALL_BINARY=0 pnpm install --frozen-lockfile -pnpm add typeorm@0.13.11 pnpm run build pnpm start ``` diff --git a/package.json b/package.json index 0d06415a1..e918a64fd 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "scripts": { "preinstall": "npx only-allow pnpm", + "postinstall": "node postinstall-win.js", "dev": "nodemon -e ts --watch server --watch overseerr-api.yml -e .json,.ts,.yml -x ts-node -r tsconfig-paths/register --files --project server/tsconfig.json server/index.ts", "build:server": "tsc --project server/tsconfig.json && copyfiles -u 2 server/templates/**/*.{html,pug} dist/templates && tsc-alias -p server/tsconfig.json", "build:next": "next build", diff --git a/postinstall-win.js b/postinstall-win.js new file mode 100644 index 000000000..aa3650991 --- /dev/null +++ b/postinstall-win.js @@ -0,0 +1,13 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const fs = require('fs'); +const path = require('path'); +const { execSync } = require('child_process'); + +if (process.platform === 'win32') { + const typeormPath = path.resolve('node_modules/typeorm'); + + if (fs.existsSync(typeormPath)) { + process.stdout.write('> Installing typeorm@0.3.11 for Windows\n'); + execSync('pnpm add typeorm@0.3.11', { stdio: 'inherit' }); + } +}