From ac0dd5e4b364d8174b62ae2f17d690864bae7294 Mon Sep 17 00:00:00 2001 From: Jack Kavanagh Date: Thu, 5 Jan 2023 14:17:34 +0100 Subject: [PATCH] use engines config in order to support nix-shell (#5521) * add shell.nix * use engines * fix engine range * fix --- package-lock.json | 5 ++++- package.json | 7 +++++-- scripts/check-version.js | 31 ------------------------------- shell.nix | 10 ++++++++++ 4 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 scripts/check-version.js create mode 100644 shell.nix diff --git a/package-lock.json b/package-lock.json index f3650c072..49259b628 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,6 @@ "": { "name": "insomnia", "version": "1.0.0", - "hasInstallScript": true, "license": "MIT", "devDependencies": { "@jest/globals": "^28.1.0", @@ -37,6 +36,10 @@ "ts-jest": "^28.0.1", "type-fest": "^2.12.0", "typescript": "^4.5.5" + }, + "engines": { + "node": ">=16.17 <17", + "npm": ">=8.15.0" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index deaabb49e..5ed6b3a49 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,16 @@ "url": "https://github.com/kong/insomnia/issues" }, "homepage": "https://github.com/kong/insomnia#readme", + "engines":{ + "node": ">=16.17 <17", + "npm": ">=8.15.0" + }, "scripts": { "build": "lerna run build --parallel", "lint": "lerna run lint --stream --no-bail", "lint:markdown": "markdownlint-cli2 \"**/*.md\" \"#**/node_modules\"", "lint:fix": "lerna run lint:fix --stream --no-bail", - "bootstrap": "npm install && lerna bootstrap && lerna run --stream bootstrap", + "bootstrap": " npx -y check-engine && npm install && lerna bootstrap && lerna run --stream bootstrap", "version": "lerna version", "clean": "lerna run clean --parallel --stream && lerna clean --yes && rimraf node_modules **/*.tsbuildinfo", "test": "lerna run --stream --parallel test", @@ -28,7 +32,6 @@ "app-build": "npm run build --prefix packages/insomnia", "app-package": "npm run build --prefix packages/insomnia && npm run package --prefix packages/insomnia", "app-bump-version": "npm run bump-version --prefix packages/insomnia", - "preinstall": "node ./scripts/check-version.js", "test:smoke:dev": "npm run test:dev --prefix packages/insomnia-smoke-test -- --project=Smoke", "test:smoke:build": "npm run test:build --prefix packages/insomnia-smoke-test -- --project=Smoke", "test:smoke:package": "npm run test:package --prefix packages/insomnia-smoke-test -- --project=Smoke", diff --git a/scripts/check-version.js b/scripts/check-version.js deleted file mode 100644 index 735fd4d5f..000000000 --- a/scripts/check-version.js +++ /dev/null @@ -1,31 +0,0 @@ -// TODO(TSCONVERSION) convert to TypeScript? -const fs = require('fs'); - -const GREEN_FG = '\x1b[32m'; -const RED_FG = '\x1b[31m'; -const YELLOW_FG = '\x1b[33m'; -const UNDERSCORE = '\x1b[4m'; -const BRIGHT = '\x1b[1m'; -const RESET = '\x1b[0m'; - -const foundNodeVersion = process.versions.node; -const expectedNodeVersion = fs - .readFileSync('.nvmrc') - .toString() - .trim(); - -if (foundNodeVersion !== expectedNodeVersion) { - console.log(`${BRIGHT}${RED_FG}Incorrect node version installed ...${RESET}\n`); - console.log(`Current node version -> ${RED_FG}${foundNodeVersion}${RESET}`); - console.log(`Expected node version -> ${GREEN_FG}${expectedNodeVersion}${RESET}`); - console.log(); - console.log( - `One solution to manage multiple versions of node is nvm, visit ${UNDERSCORE}https://github.com/nvm-sh/nvm${RESET}`, - ); - console.log(); - console.log( - `${BRIGHT}${YELLOW_FG}Remember to 'npm run clean && npm run bootstrap' after installing the expected version.${RESET}`, - ); - console.log(); - process.exit(1); -} diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..944db6e21 --- /dev/null +++ b/shell.nix @@ -0,0 +1,10 @@ +with import {}; + +mkShell { + nativeBuildInputs = [ + nodejs-16_x + electron_22 + ]; + + ELECTRON_OVERRIDE_DIST_PATH = "${electron_22}/bin/"; +}