Skip to content

Commit 5d72c14

Browse files
committed
chore: move checkForMultipleVersions into a yarn script
1 parent d908ac6 commit 5d72c14

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.github/workflows/node.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,6 @@ jobs:
748748
CI: true
749749
- name: Run check
750750
run: |
751-
node scripts/checkForMultipleVersions.mjs
751+
yarn validate:versions
752752
env:
753753
CI: true

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
"meteor:run": "cd meteor && meteor yarn start",
2626
"lint": "run lint:meteor && run lint:packages",
2727
"unit": "run unit:meteor && run unit:packages",
28-
"validate:release": "yarn install && run install-and-build && run validate:release:packages && run validate:release:meteor",
28+
"validate:release": "yarn install && run install-and-build && run validate:versions && run validate:release:packages && run validate:release:meteor",
2929
"validate:release:meteor": "cd meteor && meteor yarn validate:prod-dependencies && meteor yarn license-validate && meteor yarn lint && meteor yarn test",
3030
"validate:release:packages": "cd packages && run validate:dependencies && run test",
31+
"validate:versions": "node scripts/checkForMultipleVersions.mjs",
3132
"meteor": "cd meteor && meteor",
3233
"docs:serve": "cd packages && run docs:serve",
3334
"reset": "node scripts/reset.mjs",

scripts/checkForMultipleVersions.mjs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { buildDepTreeFromFiles } from "snyk-nodejs-lockfile-parser";
22

3+
function hr() {
4+
// write regular dashes if this is a "simple" output stream ()
5+
if (!process.stdout.hasColors || !process.stdout.hasColors())
6+
return "-".repeat(process.stdout.columns ?? 40);
7+
return '─'.repeat(process.stdout.columns ?? 40)
8+
}
9+
310
/**
411
* These are the libs we want to consider.
512
* Its an array of arrays, to allow for multiple names to be treated as one package
@@ -58,6 +65,10 @@ await addDepsForRoot("./packages", "live-status-gateway");
5865

5966
let hasFailure = false;
6067

68+
console.log(hr())
69+
console.log(" 🔢 Checking dependency version consistency...")
70+
console.log(hr())
71+
6172
// check each library
6273
for (const libName of libsToConsider) {
6374
const allVersions = new Set();
@@ -73,11 +84,11 @@ for (const libName of libsToConsider) {
7384
// output some info
7485
const str = Array.from(allVersions).join(", ");
7586
if (allVersions.size === 0) {
76-
console.log(`No versions of "${nameStr}" installed`);
87+
console.log(`No versions of "${nameStr}" installed`);
7788
} else if (allVersions.size === 1) {
78-
console.log(`Single version of "${nameStr}" installed: ${str}`);
89+
console.log(`Single version of "${nameStr}" installed: ${str}`);
7990
} else {
80-
console.error(`Multiple versions of "${nameStr}" installed: ${str}`);
91+
console.error(`⚠️ Multiple versions of "${nameStr}" installed: ${str}`);
8192
hasFailure = true;
8293
}
8394
}

0 commit comments

Comments
 (0)