From 07bc0325eee555c9645efd6d2dc9dd6abb93da7f Mon Sep 17 00:00:00 2001
From: chris48s <chris48s@users.noreply.github.com>
Date: Tue, 17 May 2022 21:23:06 +0100
Subject: [PATCH] simplify NPM strict checks (#7973)

* simplify engine-strict/strict-peer-deps checks

* disable engine-strict for node 12/14 package tests

* update docs

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
---
 .circleci/config.yml | 24 ++++--------------------
 .npmrc               |  2 ++
 Dockerfile           |  2 +-
 doc/TUTORIAL.md      |  2 +-
 package.json         |  4 ++--
 5 files changed, 10 insertions(+), 24 deletions(-)
 create mode 100644 .npmrc

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 89eedd2b39..9d1d9086d0 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -7,7 +7,6 @@ main_steps: &main_steps
     - run:
         name: Install dependencies
         command: |
-          npm install --dry-run
           npm ci
         environment:
           # https://docs.cypress.io/guides/getting-started/installing-cypress.html#Skipping-installation
@@ -50,7 +49,6 @@ integration_steps: &integration_steps
     - run:
         name: Install dependencies
         command: |
-          npm install --dry-run
           npm ci
         environment:
           CYPRESS_INSTALL_BINARY: 0
@@ -73,7 +71,6 @@ services_steps: &services_steps
     - run:
         name: Install dependencies
         command: |
-          npm install --dry-run
           npm ci
         environment:
           CYPRESS_INSTALL_BINARY: 0
@@ -116,6 +113,7 @@ package_steps: &package_steps
           MOCHA_FILE: junit/badge-maker/v12/results.xml
           NODE_VERSION: v12
           CYPRESS_INSTALL_BINARY: 0
+          NPM_CONFIG_ENGINE_STRICT: 'false'
         name: Run package tests on Node 12
         command: scripts/run_package_tests.sh
 
@@ -125,6 +123,7 @@ package_steps: &package_steps
           MOCHA_FILE: junit/badge-maker/v14/results.xml
           NODE_VERSION: v14
           CYPRESS_INSTALL_BINARY: 0
+          NPM_CONFIG_ENGINE_STRICT: 'false'
         name: Run package tests on Node 14
         command: scripts/run_package_tests.sh
 
@@ -144,9 +143,6 @@ jobs:
   main:
     docker:
       - image: cimg/node:16.15
-        environment:
-          NPM_CONFIG_ENGINE_STRICT: 'true'
-          NPM_CONFIG_STRICT_PEER_DEPS: 'true'
 
     <<: *main_steps
 
@@ -159,9 +155,6 @@ jobs:
   integration:
     docker:
       - image: cimg/node:16.15
-        environment:
-          NPM_CONFIG_ENGINE_STRICT: 'true'
-          NPM_CONFIG_STRICT_PEER_DEPS: 'true'
       - image: redis
 
     <<: *integration_steps
@@ -196,16 +189,13 @@ jobs:
   frontend:
     docker:
       - image: cimg/node:16.15
-        environment:
-          NPM_CONFIG_ENGINE_STRICT: 'true'
-          NPM_CONFIG_STRICT_PEER_DEPS: 'true'
+
     steps:
       - checkout
 
       - run:
           name: Install dependencies
           command: |
-            npm install --dry-run
             npm ci
           environment:
             CYPRESS_INSTALL_BINARY: 0
@@ -243,9 +233,6 @@ jobs:
   services:
     docker:
       - image: cimg/node:16.15
-        environment:
-          NPM_CONFIG_ENGINE_STRICT: 'true'
-          NPM_CONFIG_STRICT_PEER_DEPS: 'true'
 
     <<: *services_steps
 
@@ -258,9 +245,7 @@ jobs:
   e2e:
     docker:
       - image: cypress/base:16.14.0
-        environment:
-          NPM_CONFIG_ENGINE_STRICT: 'true'
-          NPM_CONFIG_STRICT_PEER_DEPS: 'true'
+
     steps:
       - checkout
 
@@ -272,7 +257,6 @@ jobs:
       - run:
           name: Install dependencies
           command: |
-            npm install --dry-run
             npm ci
 
       - run:
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000000..7dc0c227e2
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1,2 @@
+engine-strict=true
+strict-peer-deps=true
diff --git a/Dockerfile b/Dockerfile
index 7bbb3d5896..c63fe69744 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,7 +9,7 @@ COPY package.json package-lock.json /usr/src/app/
 COPY badge-maker /usr/src/app/badge-maker/
 
 RUN apk add python3 make g++
-RUN npm install -g "npm@>=7"
+RUN npm install -g "npm@>=8"
 # We need dev deps to build the front end. We don't need Cypress, though.
 RUN NODE_ENV=development CYPRESS_INSTALL_BINARY=0 npm ci
 
diff --git a/doc/TUTORIAL.md b/doc/TUTORIAL.md
index ab81402c3e..900d0740cd 100644
--- a/doc/TUTORIAL.md
+++ b/doc/TUTORIAL.md
@@ -25,7 +25,7 @@ and learn about the [GitHub workflow](http://try.github.io/).
 
 #### Node, NPM
 
-Node >=16 and NPM >=7 is required. If you don't already have them,
+Node >=16 and NPM >=8 is required. If you don't already have them,
 install node and npm: https://nodejs.org/en/download/
 
 ### Setup a dev install
diff --git a/package.json b/package.json
index 3d58f0ffed..190b9a2d54 100644
--- a/package.json
+++ b/package.json
@@ -241,8 +241,8 @@
     "url": "^0.11.0"
   },
   "engines": {
-    "node": "^16.13.0",
-    "npm": ">=7.0.0"
+    "node": ">=16.13.0",
+    "npm": ">=8.0.0"
   },
   "type": "module",
   "collective": {
-- 
GitLab