Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ jobs:
npm run lint
npm run test-docker

- name: Test npx double-package install
run: |
npm pack --workspace packages/validator
npm pack --workspace packages/ruleset

# Test without a custom ruleset
npx --yes \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the --prefer-online flag would be helpful to avoid reusing stale cached data. According to the NPM docs it does the following:

If true, staleness checks for cached data will be forced, making the CLI look for updates immediately even for fresh package data.

Suggested change
# Test without a custom ruleset
npx --yes \
# Test without a custom ruleset
npx --yes --prefer-online \

-p ./ibm-cloud-openapi-ruleset-*.tgz \
-p ./ibm-openapi-validator-*.tgz \
lint-openapi packages/validator/test/cli-validator/mock-files/oas3/clean.yml

# Test with a custom .spectral.js
printf "const ibmRuleset = require('@ibm-cloud/openapi-ruleset');\nmodule.exports = { extends: [[ibmRuleset, 'all']], rules: {} };\n" > /tmp/test-spectral.js

npx --yes \
-p ./ibm-cloud-openapi-ruleset-*.tgz \
-p ./ibm-openapi-validator-*.tgz \
lint-openapi --ruleset /tmp/test-spectral.js \
packages/validator/test/cli-validator/mock-files/oas3/clean.yml

publish-release:
needs: build
name: semantic-release
Expand Down
168 changes: 16 additions & 152 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
"proxy-agent": "6.3.0",
"micromatch": "4.0.8",
"jsonpath-plus": "10.3.0",
"rollup": "2.80.0",
"@stoplight/spectral-core": {
"minimatch": "3.1.5"
}
"rollup": "2.80.0"
}
}
4 changes: 2 additions & 2 deletions packages/ruleset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@ibm-cloud/openapi-ruleset-utilities": "1.9.2",
"@stoplight/spectral-formats": "1.8.2",
"@stoplight/spectral-functions": "1.10.1",
"@stoplight/spectral-rulesets": "1.22.1",
"@stoplight/spectral-rulesets": "1.22.7",
"chalk": "4.1.2",
"inflected": "2.1.0",
"jsonschema": "1.5.0",
Expand All @@ -35,7 +35,7 @@
"validator": "13.15.23"
},
"devDependencies": {
"@stoplight/spectral-core": "1.21.0",
"@stoplight/spectral-core": "1.23.1",
"jest": "29.7.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"pkg": "echo no executables to build in this package"
},
"devDependencies": {
"@stoplight/spectral-core": "1.21.0",
"@stoplight/spectral-core": "1.23.1",
"jest": "29.7.0",
"typescript": "5.8.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@ibm-cloud/openapi-ruleset": "1.33.13",
"@ibm-cloud/openapi-ruleset-utilities": "1.9.2",
"@stoplight/spectral-cli": "6.15.0",
"@stoplight/spectral-core": "1.21.0",
"@stoplight/spectral-core": "1.23.1",
"@stoplight/spectral-parsers": "1.0.5",
"@stoplight/spectral-ref-resolver": "1.0.5",
"ajv": "8.18.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2017 - 2025 IBM Corporation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright 2017 - 2025 IBM Corporation.
* Copyright 2026 IBM Corporation.

* SPDX-License-Identifier: Apache2.0
*/

'use strict';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to use strict mode here. Actually we don't really use it anymore if you check any of the recent files.


const semver = require('semver');

const validatorPkg = require('../../../package.json');
const rulesetPkg = require('../../../../ruleset/package.json');
const spectralRulesetsPkg = require('../../../../../node_modules/@stoplight/spectral-rulesets/package.json');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These relative paths look a bit fragile. Do you think something like this would work?

const spectralRulesetsPkg = require(
  require.resolve('@stoplight/spectral-rulesets/package.json')
);


// The version of @stoplight/spectral-core declared in each package.json.
// These must stay in sync to avoid an instanceof Ruleset mismatch.
const validatorPin = validatorPkg.dependencies['@stoplight/spectral-core'];
const rulesetDevPin = rulesetPkg.devDependencies['@stoplight/spectral-core'];
const spectralRulesetsRange =
spectralRulesetsPkg.dependencies['@stoplight/spectral-core'];

describe('spectral-core version sync', function () {
it('validator and ruleset devDependency should pin the same spectral-core version', function () {
expect(validatorPin).toEqual(rulesetDevPin);
});

it('validator spectral-core pin should satisfy the range required by spectral-rulesets', function () {
const satisfies = semver.satisfies(validatorPin, spectralRulesetsRange);
expect(satisfies).toBe(true);
});
});
Loading