DEV: Prevent npm usage (#13945)

DEV: Prevent npm usage (#13945)

We rely on yarn workspaces so we don’t want people using npm in the repo by accident.

Also updated the required node version to 12+.

Not sure about the min yarn version – the latest one could be missing in various CI-like envs, so I might change it yet. Downgraded yarn to “>= 1.21.1” (the oldest of “current” versions, tagged “legacy”)

diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/.npmrc b/app/assets/javascripts/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/admin/.npmrc b/app/assets/javascripts/admin/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/admin/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/admin/package.json b/app/assets/javascripts/admin/package.json
index 56274a2..199c83d 100644
--- a/app/assets/javascripts/admin/package.json
+++ b/app/assets/javascripts/admin/package.json
@@ -46,7 +46,9 @@
     "loader.js": "^4.7.0"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "default"
diff --git a/app/assets/javascripts/discourse-common/.npmrc b/app/assets/javascripts/discourse-common/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/discourse-common/package.json b/app/assets/javascripts/discourse-common/package.json
index 26b9d92..61de386 100644
--- a/app/assets/javascripts/discourse-common/package.json
+++ b/app/assets/javascripts/discourse-common/package.json
@@ -46,7 +46,9 @@
     "loader.js": "^4.7.0"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "octane"
diff --git a/app/assets/javascripts/discourse-hbr/.npmrc b/app/assets/javascripts/discourse-hbr/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/discourse-hbr/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/discourse-hbr/package.json b/app/assets/javascripts/discourse-hbr/package.json
index 217d246..f443450 100644
--- a/app/assets/javascripts/discourse-hbr/package.json
+++ b/app/assets/javascripts/discourse-hbr/package.json
@@ -46,7 +46,9 @@
     "loader.js": "^4.7.0"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "octane"
diff --git a/app/assets/javascripts/discourse-widget-hbs/.npmrc b/app/assets/javascripts/discourse-widget-hbs/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/discourse-widget-hbs/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/discourse-widget-hbs/package.json b/app/assets/javascripts/discourse-widget-hbs/package.json
index 8353998..4787f26 100644
--- a/app/assets/javascripts/discourse-widget-hbs/package.json
+++ b/app/assets/javascripts/discourse-widget-hbs/package.json
@@ -46,7 +46,9 @@
     "loader.js": "^4.7.0"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "octane"
diff --git a/app/assets/javascripts/discourse/.npmrc b/app/assets/javascripts/discourse/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/discourse/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc b/app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/discourse/lib/bootstrap-json/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/package.json b/app/assets/javascripts/discourse/lib/bootstrap-json/package.json
index c79e0bc..50d5b34 100644
--- a/app/assets/javascripts/discourse/lib/bootstrap-json/package.json
+++ b/app/assets/javascripts/discourse/lib/bootstrap-json/package.json
@@ -9,5 +9,10 @@
       "history-support-middleware",
       "proxy-server-middleware"
     ]
+  },
+  "engines": {
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   }
 }
diff --git a/app/assets/javascripts/discourse/package.json b/app/assets/javascripts/discourse/package.json
index ae73505..99aaf01 100644
--- a/app/assets/javascripts/discourse/package.json
+++ b/app/assets/javascripts/discourse/package.json
@@ -64,7 +64,9 @@
     "virtual-dom": "^2.1.1"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "default"
diff --git a/app/assets/javascripts/pretty-text/.npmrc b/app/assets/javascripts/pretty-text/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/pretty-text/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/pretty-text/package.json b/app/assets/javascripts/pretty-text/package.json
index 03c7d14..f2823ac 100644
--- a/app/assets/javascripts/pretty-text/package.json
+++ b/app/assets/javascripts/pretty-text/package.json
@@ -45,7 +45,9 @@
     "loader.js": "^4.7.0"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "octane"
diff --git a/app/assets/javascripts/select-kit/.npmrc b/app/assets/javascripts/select-kit/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/select-kit/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/select-kit/package.json b/app/assets/javascripts/select-kit/package.json
index 92bab1d..67f0723 100644
--- a/app/assets/javascripts/select-kit/package.json
+++ b/app/assets/javascripts/select-kit/package.json
@@ -44,7 +44,9 @@
     "loader.js": "^4.7.0"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "octane"
diff --git a/app/assets/javascripts/truth-helpers/.npmrc b/app/assets/javascripts/truth-helpers/.npmrc
new file mode 100644
index 0000000..c42da84
--- /dev/null
+++ b/app/assets/javascripts/truth-helpers/.npmrc
@@ -0,0 +1 @@
+engine-strict = true
diff --git a/app/assets/javascripts/truth-helpers/package.json b/app/assets/javascripts/truth-helpers/package.json
index 23dbcb9..68668bf 100644
--- a/app/assets/javascripts/truth-helpers/package.json
+++ b/app/assets/javascripts/truth-helpers/package.json
@@ -44,7 +44,9 @@
     "loader.js": "^4.7.0"
   },
   "engines": {
-    "node": "8.* || >= 10.*"
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   },
   "ember": {
     "edition": "octane"
diff --git a/package.json b/package.json
index 7c41208..39a7c9e 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,11 @@
     "lodash": "4.17.21"
   },
   "scripts": {
-    "preinstall": "node -e \"if(process.env.npm_execpath.indexOf('yarn') === -1) throw new Error('NPM is not supported, please use Yarn instead. ')\"",
     "postinstall": "yarn --cwd app/assets/javascripts/discourse"
+  },
+  "engines": {
+    "node": ">= 12.*",
+    "npm": "please-use-yarn",
+    "yarn": ">= 1.21.1"
   }
 }

GitHub sha: fbd1cd5fe1d5e0cf09e7b06e39819b8942abdbf5

This commit appears in #13945 which was approved by eviltrout. It was merged by CvX.