Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into create-redirect
Browse files Browse the repository at this point in the history
* master:
  0.17.0
  Prepare 0.17.0
  [version-sort] do not push pre-releases of the latest stable version (#148)
  🐛make compare-versions a dependency (#142)
  • Loading branch information
Katy DeCorah committed Jul 8, 2019
2 parents 6c37c34 + 6ac908c commit 56b30ad
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Master
## 0.17.0

* Add data attribute to prevent Swiftype from indexing sidebar content on `PageLayout`. [#146](https://github.com/mapbox/dr-ui/pull/146)
* Add compare-versions as a dependency to support `helpers/version-sort.js`. [#142](https://github.com/mapbox/dr-ui/pull/142)
* Fix `version-sort` helper function so it does not push pre-releases of the latest stable version. [#148](https://github.com/mapbox/dr-ui/pull/148)

## 0.16.2

Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapbox/dr-ui",
"version": "0.16.2",
"version": "0.17.0",
"description": "Mapbox frontend tools for documentation websites.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -38,7 +38,6 @@
"babel-eslint": "^8.2.6",
"babelify": "^10.0.0",
"budo": "^11.6.0",
"compare-versions": "^3.4.0",
"cpy": "^7.0.1",
"cpy-cli": "^2.0.0",
"del": "^3.0.0",
Expand Down Expand Up @@ -70,6 +69,7 @@
"@elastic/search-ui-site-search-connector": "^0.10.0",
"@mapbox/mr-ui": "^0.7.0",
"classnames": "^2.2.6",
"compare-versions": "^3.4.0",
"debounce": "^1.2.0",
"downshift": "^3.2.7",
"hastscript": "^5.0.0",
Expand Down
8 changes: 7 additions & 1 deletion src/helpers/version-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ export function sortVersions(versions) {
sortPreReleases
.sort(sortBy('version'))
.reverse()
.map(v => v.version);
.reduce((arr, v) => {
// do not push pre releases of lastest stable
if (!allLatestVersion.test(v.version)) {
arr.push(v.version);
}
return arr;
}, []);

const versionsToDisplay = allVersionsOrdered.filter(version => {
return !/^(\d|\.)+-(alpha|beta|rc|pre).+/.test(version);
Expand Down
32 changes: 29 additions & 3 deletions tests/version-sort.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ describe('ios', () => {
});

test(`newestPreRelease`, () => {
expect(sortVersions(allIosVersions).newestPreRelease).toEqual([
'5.0.0-beta.1'
]);
expect(sortVersions(allIosVersions).newestPreRelease).toEqual([]);
});
test(`versionsToDisplay`, () => {
expect(sortVersions(allIosVersions).versionsToDisplay).toEqual([
Expand Down Expand Up @@ -314,4 +312,32 @@ describe('ios', () => {
test(`newestPreRelease, no pre releases`, () => {
expect(sortVersions(['4.9.0', '4.8.0']).newestPreRelease).toEqual([]);
});

test('dont show pre releases of latest stable', () => {
expect(
sortVersions([
'5.1.0',
'5.1.0-beta.1',
'5.1.0-alpha.2',
'5.1.0-alpha.1',
'5.0.0',
'4.12.0-beta.1',
'4.11.0'
])
).toEqual({
allLatestVersion: /^5.1.0-.+/,
allVersionsOrdered: [
'5.1.0',
'5.1.0-beta.1',
'5.1.0-alpha.2',
'5.1.0-alpha.1',
'5.0.0',
'4.12.0-beta.1',
'4.11.0'
],
latestStable: '5.1.0',
newestPreRelease: [],
versionsToDisplay: ['5.1.0', '5.0.0', '4.11.0']
});
});
});

0 comments on commit 56b30ad

Please sign in to comment.