From 6b52e4b1111d595f3501ebcaaf179bc7ff90b5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 21 Nov 2022 12:53:11 +0100 Subject: [PATCH] ci: Block execution of `npm install` (no-changelog) (#4662) ci: block execution of `npm install` (no-changelog) --- package.json | 1 + scripts/block-npm-install.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 scripts/block-npm-install.js diff --git a/package.json b/package.json index 3edc293860..2fb6fde935 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "packageManager": "pnpm@7.14.2", "scripts": { + "preinstall": "node scripts/block-npm-install.js", "build": "turbo run build", "dev": "turbo run dev --parallel", "clean": "turbo run clean --parallel", diff --git a/scripts/block-npm-install.js b/scripts/block-npm-install.js new file mode 100644 index 0000000000..4fbcda5b97 --- /dev/null +++ b/scripts/block-npm-install.js @@ -0,0 +1,12 @@ +const { npm_config_user_agent: UA } = process.env; +const [packageManager] = (UA ?? '').split(' '); +const [name, version] = packageManager.split('/'); +if (name !== 'pnpm') { + const suggestion = '\033[1;92mpnpm\033[0;31m'; + console.error('\033[0;31m'); + console.error('╭───────────────────────────────────────────╮'); + console.error(`│\tPlease use ${suggestion} instead of ${name} \t │`); + console.error('╰───────────────────────────────────────────╯'); + console.error('\033[0m'); + process.exit(1); +}