diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 2f06311b1..4a498cd60 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,3 +1,10 @@ +# [@stoplight/spectral-cli-v6.4.0](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-cli-v6.3.0...@stoplight/spectral-cli-v6.4.0) (2022-05-12) + + +### Features + +* **cli:** sort linting results alphabetically ([#2147](https://github.com/stoplightio/spectral/issues/2147)) ([84d48cf](https://github.com/stoplightio/spectral/commit/84d48cf5e02780f0cbb9ae9074c03a618c2bc462)) + # [@stoplight/spectral-cli-v6.3.0](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-cli-v6.2.1...@stoplight/spectral-cli-v6.3.0) (2022-03-03) diff --git a/packages/cli/package.json b/packages/cli/package.json index c3b86ebb8..74821dd38 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@stoplight/spectral-cli", - "version": "6.3.0", + "version": "6.4.0", "homepage": "https://github.com/stoplightio/spectral", "bugs": "https://github.com/stoplightio/spectral/issues", "author": "Stoplight ", diff --git a/packages/cli/src/services/__tests__/__fixtures__/invalid-stoplight-info-document.json b/packages/cli/src/services/__tests__/__fixtures__/invalid-stoplight-info-document.json new file mode 100644 index 000000000..1a71c21b7 --- /dev/null +++ b/packages/cli/src/services/__tests__/__fixtures__/invalid-stoplight-info-document.json @@ -0,0 +1,5 @@ +{ + "info": { + "title": "no stoplight :(" + } +} diff --git a/packages/cli/src/services/__tests__/linter.test.ts b/packages/cli/src/services/__tests__/linter.test.ts index 84ed44522..edcda750e 100644 --- a/packages/cli/src/services/__tests__/linter.test.ts +++ b/packages/cli/src/services/__tests__/linter.test.ts @@ -118,8 +118,8 @@ describe('Linter service', () => { it('given a list of files is provided, outputs issues for each file', () => { const documents = [ + join(__dirname, `./__fixtures__/invalid-stoplight-info-document.json`), join(__dirname, `./__fixtures__/missing-stoplight-info-document.json`), - join(__dirname, `./__fixtures__/missing-stoplight-info-document-copy.json`), ]; return expect(run(['lint', ...documents].join(' '))).resolves.toEqual([ @@ -142,6 +142,29 @@ describe('Linter service', () => { ]); }); + it('sorts linting results in an alphabetical order', () => { + const documents = [ + join(__dirname, `./__fixtures__/missing-stoplight-info-document.json`), + join(__dirname, `./__fixtures__/openapi-3.0-valid.yaml`), + join(__dirname, `./__fixtures__/invalid-stoplight-info-document.json`), + ]; + + return expect(run(['lint', ...documents].join(' '))).resolves.toEqual([ + expect.objectContaining({ + code: 'info-matches-stoplight', + source: join(__dirname, `./__fixtures__/invalid-stoplight-info-document.json`), + }), + expect.objectContaining({ + code: 'info-matches-stoplight', + source: join(__dirname, `./__fixtures__/missing-stoplight-info-document.json`), + }), + expect.objectContaining({ + code: 'info-matches-stoplight', + source: join(__dirname, `./__fixtures__/openapi-3.0-valid.yaml`), + }), + ]); + }); + describe('when glob is provided', () => { const documents = join(__dirname, `./__fixtures__/missing-stoplight-info*.json`); diff --git a/packages/cli/src/services/linter/utils/listFiles.ts b/packages/cli/src/services/linter/utils/listFiles.ts index 2edd01730..8049b2462 100644 --- a/packages/cli/src/services/linter/utils/listFiles.ts +++ b/packages/cli/src/services/linter/utils/listFiles.ts @@ -10,6 +10,8 @@ async function match(pattern: fg.Pattern | fg.Pattern[]): Promise { return (await fg(pattern, GLOB_OPTIONS)).map(normalize); } +const compareString = (a: string, b: string): number => a.localeCompare(b); + export async function listFiles(patterns: string[], ignoreUnmatchedGlobs: boolean): Promise<[string[], string[]]> { const { files, urls } = patterns.reduce<{ files: string[]; @@ -49,5 +51,5 @@ export async function listFiles(patterns: string[], ignoreUnmatchedGlobs: boolea ); } - return [[...urls, ...filesFound], fileSearchWithoutResult]; // let's normalize OS paths produced by fast-glob to have consistent paths across all platforms + return [[...urls, ...filesFound].sort(compareString), fileSearchWithoutResult]; // let's normalize OS paths produced by fast-glob to have consistent paths across all platforms } diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 8c51d8f84..566350b39 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,3 +1,10 @@ +# [@stoplight/spectral-core-v1.12.2](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-core-v1.12.1...@stoplight/spectral-core-v1.12.2) (2022-05-18) + + +### Bug Fixes + +* **core:** bump nimma from 0.2.0 to 0.2.1 ([#2157](https://github.com/stoplightio/spectral/issues/2157)) ([4d5ebeb](https://github.com/stoplightio/spectral/commit/4d5ebebb65cb8f6c44faa5b629311f5b25dd6bfe)) + # [@stoplight/spectral-core-v1.12.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-core-v1.12.0...@stoplight/spectral-core-v1.12.1) (2022-04-29) diff --git a/packages/core/package.json b/packages/core/package.json index 0e22bd94f..b02c2a68b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@stoplight/spectral-core", - "version": "1.12.1", + "version": "1.12.2", "sideEffects": false, "homepage": "https://github.com/stoplightio/spectral", "bugs": "https://github.com/stoplightio/spectral/issues", @@ -38,13 +38,13 @@ }, "dependencies": { "@stoplight/better-ajv-errors": "1.0.1", - "@stoplight/json": "~3.17.1", + "@stoplight/json": "~3.18.1", "@stoplight/lifecycle": "2.3.2", "@stoplight/path": "1.3.2", "@stoplight/spectral-parsers": "^1.0.0", "@stoplight/spectral-ref-resolver": "^1.0.0", "@stoplight/spectral-runtime": "^1.0.0", - "@stoplight/types": "13.0.0", + "@stoplight/types": "13.1.0", "@types/json-schema": "^7.0.7", "ajv": "^8.6.0", "ajv-errors": "~3.0.0", @@ -54,7 +54,7 @@ "lodash": "~4.17.21", "lodash.topath": "^4.5.2", "minimatch": "3.0.4", - "nimma": "0.2.0", + "nimma": "0.2.1", "pony-cause": "^1.0.0", "simple-eval": "1.0.0", "tslib": "^2.3.0" diff --git a/yarn.lock b/yarn.lock index 87c74c58d..9ad33328b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2298,7 +2298,7 @@ __metadata: languageName: node linkType: hard -"@stoplight/json@npm:3.17.0, @stoplight/json@npm:^3.17.0, @stoplight/json@npm:~3.17.0, @stoplight/json@npm:~3.17.1": +"@stoplight/json@npm:3.17.0, @stoplight/json@npm:~3.17.0, @stoplight/json@npm:~3.17.1": version: 3.17.0 resolution: "@stoplight/json@npm:3.17.0" dependencies: @@ -2311,6 +2311,19 @@ __metadata: languageName: node linkType: hard +"@stoplight/json@npm:^3.17.0, @stoplight/json@npm:~3.18.1": + version: 3.18.1 + resolution: "@stoplight/json@npm:3.18.1" + dependencies: + "@stoplight/ordered-object-literal": ^1.0.2 + "@stoplight/types": ^13.0.0 + jsonc-parser: ~2.2.1 + lodash: ^4.17.21 + safe-stable-stringify: ^1.1 + checksum: 9df3e06421541b6d7f0fbec3f928e67f0d46ef8d4cf79986345164551baef727580e85659c6b9658be578eecd253a6eb23dbe04bccf074d251e6b17a5fddf0a8 + languageName: node + linkType: hard + "@stoplight/lifecycle@npm:2.3.2": version: 2.3.2 resolution: "@stoplight/lifecycle@npm:2.3.2" @@ -2381,7 +2394,7 @@ __metadata: resolution: "@stoplight/spectral-core@workspace:packages/core" dependencies: "@stoplight/better-ajv-errors": 1.0.1 - "@stoplight/json": ~3.17.1 + "@stoplight/json": ~3.18.1 "@stoplight/lifecycle": 2.3.2 "@stoplight/path": 1.3.2 "@stoplight/spectral-formats": "*" @@ -2389,7 +2402,7 @@ __metadata: "@stoplight/spectral-parsers": "*" "@stoplight/spectral-ref-resolver": ^1.0.0 "@stoplight/spectral-runtime": ^1.0.0 - "@stoplight/types": 13.0.0 + "@stoplight/types": 13.1.0 "@stoplight/yaml": ^4.2.2 "@types/json-schema": ^7.0.7 "@types/minimatch": ^3.0.5 @@ -2402,7 +2415,7 @@ __metadata: lodash: ~4.17.21 lodash.topath: ^4.5.2 minimatch: 3.0.4 - nimma: 0.2.0 + nimma: 0.2.1 nock: ^13.1.0 pony-cause: ^1.0.0 simple-eval: 1.0.0 @@ -2568,13 +2581,13 @@ __metadata: languageName: node linkType: hard -"@stoplight/types@npm:13.0.0": - version: 13.0.0 - resolution: "@stoplight/types@npm:13.0.0" +"@stoplight/types@npm:13.1.0, @stoplight/types@npm:^13.0.0": + version: 13.1.0 + resolution: "@stoplight/types@npm:13.1.0" dependencies: "@types/json-schema": ^7.0.4 utility-types: ^3.10.0 - checksum: 40a3995fe4f654b9761908eb41b4369d22241220e96aa0f3ace4541c160d995ddd52dee32fa574a87d7ba3f573befc40ca8708712f34e5f815162addb170f7f3 + checksum: 4caf5374e541a38f905d2e83c81beea8250990fe458fcc299d0acc75bde60d8db17ace2c98afa15ab12014b6f0b536dc8d1d22bc9ce498c60493b9267edab72f languageName: node linkType: hard @@ -9347,9 +9360,9 @@ __metadata: languageName: node linkType: hard -"nimma@npm:0.2.0": - version: 0.2.0 - resolution: "nimma@npm:0.2.0" +"nimma@npm:0.2.1": + version: 0.2.1 + resolution: "nimma@npm:0.2.1" dependencies: "@jsep-plugin/regex": ^1.0.1 "@jsep-plugin/ternary": ^1.0.2 @@ -9362,7 +9375,7 @@ __metadata: optional: true lodash.topath: optional: true - checksum: ed404ab3aca227a51e924e2b8d7d9ae75695c6c3fbdbaffee9990b42b5491f3c240ef3cdbbaffd1b9c3564bf062c936cb8b921de6b21ce8aa22733a00597fd2d + checksum: 5cba1ef3509aca12e33c34fce66cc10ceba23c989b900c26cce39e18685b7036f801924d5a892069c274f875e1616bfdcf4a36fc25400e154f9df252cfc0eb2f languageName: node linkType: hard