Skip to content

Commit

Permalink
fix: semantic version sorting (#41)
Browse files Browse the repository at this point in the history
* fix: semantic version sorting

* chore(release): 0.0.15

Co-authored-by: Konstantinos Kopanidis <[email protected]>
  • Loading branch information
kon14 and kkopanidis authored Jan 27, 2023
1 parent a960f3f commit 2922bd9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.15](https://github.com/ConduitPlatform/CLI/compare/v0.0.14...v0.0.15) (2023-01-27)


### Bug Fixes

* semantic version sorting ([183ff25](https://github.com/ConduitPlatform/CLI/commit/183ff25d0e3dcda0e4bf7a91462cdf2f316c1ad9))

### [0.0.14](https://github.com/ConduitPlatform/CLI/compare/v0.0.13...v0.0.14) (2022-12-04)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@conduitplatform/cli",
"description": "The CLI to help you when developing conduit",
"version": "0.0.14",
"version": "0.0.15",
"author": "Conduit Team",
"bin": {
"conduit": "./bin/run"
Expand Down
12 changes: 9 additions & 3 deletions src/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export async function getAvailableTags(repo: 'Conduit' | 'Conduit-UI') {
rcReleases.push(release.tag_name);
}
});
releases.sort().reverse();
rcReleases.sort().reverse();
releases.sort(semanticSort).reverse();
rcReleases.sort(semanticSort).reverse();
releases.push(...rcReleases);
if (releases.length === 0) {
CliUx.ux.error(`No supported ${repo} versions available`, { exit: -1 });
Expand Down Expand Up @@ -175,7 +175,7 @@ export async function getMatchingUiTag(conduitTag: string, uiTags: string[]) {
const tagMajor = tag.slice(baseVersion < 1 ? 3 : 1);
return parseInt(targetMajor) === parseInt(tagMajor);
});
pointReleases.sort().reverse();
pointReleases.sort(semanticSort).reverse();
const stableReleases: string[] = [];
const rcReleases: string[] = [];
pointReleases.forEach(r => {
Expand Down Expand Up @@ -225,3 +225,9 @@ export function abortAsEnemies() {
CliUx.ux.log(abortLines[Math.floor(Math.random() * abortLines.length)]);
CliUx.ux.exit(0);
}

const semanticSort = (a: string, b: string) => {
const a1 = a.split('.').map(x => +x || 0);
const b1 = b.split('.').map(x => +x || 0);
return a1.reduce((acc, curr, i) => acc || curr - b1[i] || b1.length - a1.length, 0);
};

0 comments on commit 2922bd9

Please sign in to comment.