Skip to content

Commit

Permalink
feat: loosen up peer api check to require dev ver to satisfy peer ver (
Browse files Browse the repository at this point in the history
…#936)

* feat: loosen up peer api check to require dev ver to satisfy peer ver
* fix: install semver locally in scripts
  • Loading branch information
rauno56 authored Mar 9, 2022
1 parent a228f8a commit 3ad1727
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ jobs:
- name: Install lerna
run: npm install -g lerna

- name: Install script dependencies
run: npm install

- name: Check API dependency semantics
run: lerna exec "node \$LERNA_ROOT_PATH/scripts/peer-api-check.js"
8 changes: 8 additions & 0 deletions scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "opentelemetry-contrib-scripts",
"private": true,
"license": "Apache-2.0",
"dependencies": {
"semver": "7.3.5"
}
}
6 changes: 4 additions & 2 deletions scripts/peer-api-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

const path = require('path');
const semver = require('semver');

const appRoot = process.cwd();
const packageJsonUrl = path.resolve(`${appRoot}/package.json`);
const pjson = require(packageJsonUrl);
Expand All @@ -32,10 +34,10 @@ if (peerVersion) {
`Package ${pjson.name} does't have API version pinned in dev dependencies: ${devVersion}`
);
}
if (peerVersion !== `^${devVersion}`) {
if (!semver.satisfies(devVersion, peerVersion)) {
throw new Error(
`Package ${pjson.name} depends on peer API version ${peerVersion} ` +
`but version ${devVersion} in development`
`but version ${devVersion} in development which doesn't satisfy the peer API version`
);
}
console.log(`${pjson.name} OK`);
Expand Down

0 comments on commit 3ad1727

Please sign in to comment.