Compare commits

...
2 Commits
Author SHA1 Message Date
Kuba Martin ae80d4ecaa Fix latest fetching prerelease versions. (#29)
* Fix fetching latest version to not fetch prerelease.

Signed-off-by: Kuba Martin <kubam@spacelift.io>

* Add tests.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

---------

Signed-off-by: Kuba Martin <kubam@spacelift.io>
Signed-off-by: Jakub Martin <kubam@spacelift.io>
2024-03-17 16:01:44 +01:00
dependabot[bot] d00c6817f1 chore(deps-dev): Bump husky from 8.0.3 to 9.0.11 (#27)
Bumps [husky](https://github.com/typicode/husky) from 8.0.3 to 9.0.11.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](https://github.com/typicode/husky/compare/v8.0.3...v9.0.11)

---
updated-dependencies:
- dependency-name: husky
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-21 12:22:29 +02:00
5 changed files with 194 additions and 13 deletions

No files matched your search

+1 -1
View File
@@ -61,7 +61,7 @@ async function fetchReleases (githubToken) {
const semver = __nccwpck_require__(1383);
async function findLatestVersion (versions) {
return versions.sort((a, b) => semver.rcompare(a, b))[0];
return versions.filter((v) => semver.prerelease(v) === null).sort((a, b) => semver.rcompare(a, b))[0];
}
async function findLatestVersionInRange (versions, range) {
+1 -1
View File
@@ -55,7 +55,7 @@ async function fetchReleases (githubToken) {
const semver = require('semver');
async function findLatestVersion (versions) {
return versions.sort((a, b) => semver.rcompare(a, b))[0];
return versions.filter((v) => semver.prerelease(v) === null).sort((a, b) => semver.rcompare(a, b))[0];
}
async function findLatestVersionInRange (versions, range) {
+185 -4
View File
@@ -3,6 +3,184 @@ const pkg = require('../releases');
describe('getRelease', () => {
function mockFetchReleases () {
const mockReleasesMeta = [{
tag_name: 'v1.7.0-alpha2',
assets: [{
name: 'tofu_1.7.0-alpha2_386.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.apk'
}, {
name: 'tofu_1.7.0-alpha2_386.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.deb'
}, {
name: 'tofu_1.7.0-alpha2_386.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.rpm'
}, {
name: 'tofu_1.7.0-alpha2_amd64.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.apk'
}, {
name: 'tofu_1.7.0-alpha2_amd64.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.deb'
}, {
name: 'tofu_1.7.0-alpha2_amd64.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.rpm'
}, {
name: 'tofu_1.7.0-alpha2_arm.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.apk'
}, {
name: 'tofu_1.7.0-alpha2_arm.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.deb'
}, {
name: 'tofu_1.7.0-alpha2_arm.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.rpm'
}, {
name: 'tofu_1.7.0-alpha2_arm64.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.apk'
}, {
name: 'tofu_1.7.0-alpha2_arm64.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.deb'
}, {
name: 'tofu_1.7.0-alpha2_arm64.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.rpm'
}, {
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_darwin_amd64.zip'
}, {
name: 'tofu_1.7.0-alpha2_darwin_arm64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_darwin_arm64.zip'
}, {
name: 'tofu_1.7.0-alpha2_freebsd_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_386.zip'
}, {
name: 'tofu_1.7.0-alpha2_freebsd_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_amd64.zip'
}, {
name: 'tofu_1.7.0-alpha2_freebsd_arm.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_arm.zip'
}, {
name: 'tofu_1.7.0-alpha2_linux_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_386.zip'
}, {
name: 'tofu_1.7.0-alpha2_linux_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_amd64.zip'
}, {
name: 'tofu_1.7.0-alpha2_linux_arm.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_arm.zip'
}, {
name: 'tofu_1.7.0-alpha2_linux_arm64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_arm64.zip'
}, {
name: 'tofu_1.7.0-alpha2_openbsd_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_openbsd_386.zip'
}, {
name: 'tofu_1.7.0-alpha2_openbsd_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_openbsd_amd64.zip'
}, {
name: 'tofu_1.7.0-alpha2_SHA256SUMS',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS'
}, {
name: 'tofu_1.7.0-alpha2_SHA256SUMS.pem',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS.pem'
}, {
name: 'tofu_1.7.0-alpha2_SHA256SUMS.sig',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS.sig'
}, {
name: 'tofu_1.7.0-alpha2_solaris_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_solaris_amd64.zip'
}, {
name: 'tofu_1.7.0-alpha2_windows_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_windows_386.zip'
}, {
name: 'tofu_1.7.0-alpha2_windows_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_windows_amd64.zip'
}]
}, {
tag_name: 'v1.6.0',
assets: [{
name: 'tofu_1.6.0_386.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.apk'
}, {
name: 'tofu_1.6.0_386.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.deb'
}, {
name: 'tofu_1.6.0_386.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.rpm'
}, {
name: 'tofu_1.6.0_amd64.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.apk'
}, {
name: 'tofu_1.6.0_amd64.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.deb'
}, {
name: 'tofu_1.6.0_amd64.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.rpm'
}, {
name: 'tofu_1.6.0_arm.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.apk'
}, {
name: 'tofu_1.6.0_arm.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.deb'
}, {
name: 'tofu_1.6.0_arm.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.rpm'
}, {
name: 'tofu_1.6.0_arm64.apk',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.apk'
}, {
name: 'tofu_1.6.0_arm64.deb',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.deb'
}, {
name: 'tofu_1.6.0_arm64.rpm',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.rpm'
}, {
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_darwin_amd64.zip'
}, {
name: 'tofu_1.6.0_darwin_arm64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_darwin_arm64.zip'
}, {
name: 'tofu_1.6.0_freebsd_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_386.zip'
}, {
name: 'tofu_1.6.0_freebsd_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_amd64.zip'
}, {
name: 'tofu_1.6.0_freebsd_arm.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_arm.zip'
}, {
name: 'tofu_1.6.0_linux_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_386.zip'
}, {
name: 'tofu_1.6.0_linux_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_amd64.zip'
}, {
name: 'tofu_1.6.0_linux_arm.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_arm.zip'
}, {
name: 'tofu_1.6.0_linux_arm64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_arm64.zip'
}, {
name: 'tofu_1.6.0_openbsd_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_openbsd_386.zip'
}, {
name: 'tofu_1.6.0_openbsd_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_openbsd_amd64.zip'
}, {
name: 'tofu_1.6.0_SHA256SUMS',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS'
}, {
name: 'tofu_1.6.0_SHA256SUMS.pem',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS.pem'
}, {
name: 'tofu_1.6.0_SHA256SUMS.sig',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS.sig'
}, {
name: 'tofu_1.6.0_solaris_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_solaris_amd64.zip'
}, {
name: 'tofu_1.6.0_windows_386.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_windows_386.zip'
}, {
name: 'tofu_1.6.0_windows_amd64.zip',
browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_windows_amd64.zip'
}]
}, {
tag_name: 'v1.6.0-alpha2',
assets: [{
name: 'tofu_1.6.0-alpha2_386.apk',
@@ -188,12 +366,15 @@ describe('getRelease', () => {
it.each(
[
['latest', '1.6.0-alpha2'],
['latest', '1.6.0'],
['<1.6.0-beta', '1.6.0-alpha2'],
['>1.6.0-alpha1', '1.6.0-alpha2'],
['>1.6.0-alpha1', '1.6.0'],
['>1.6.0-alpha1 <1.6.0', '1.6.0-alpha2'],
['~1.6.0-alpha', '1.6.0-alpha2'],
['<=1.6.0-alpha1', '1.6.0-alpha1']
['~1.6.0-alpha', '1.6.0'],
['<=1.6.0-alpha1', '1.6.0-alpha1'],
['>1.5.0', '1.6.0'],
['>1.5.0', '1.6.0'],
['>1.7.0-alpha', '1.7.0-alpha2']
]
)('happy path: getRelease(\'%s\') -> \'%s\'', async (input, wantVersion) => {
const want = mockFetchReleases().find(el => el.version === wantVersion);
+6 -6
View File
@@ -17,7 +17,7 @@
},
"devDependencies": {
"@vercel/ncc": "0.38.1",
"husky": "8.0.3",
"husky": "9.0.11",
"jest": "29.7.0",
"semistandard": "17.0.0"
}
@@ -3361,15 +3361,15 @@
}
},
"node_modules/husky": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz",
"integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==",
"version": "9.0.11",
"resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz",
"integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==",
"dev": true,
"bin": {
"husky": "lib/bin.js"
"husky": "bin.mjs"
},
"engines": {
"node": ">=14"
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
+1 -1
View File
@@ -27,7 +27,7 @@
},
"devDependencies": {
"@vercel/ncc": "0.38.1",
"husky": "8.0.3",
"husky": "9.0.11",
"jest": "29.7.0",
"semistandard": "17.0.0"
},