2020-01-18 00:18:09 +00:00
|
|
|
import fetch from 'isomorphic-unfetch'
|
2020-04-22 20:27:34 +00:00
|
|
|
import { VERSION, CHANGELOG_URL } from '../../data/version.js'
|
2020-01-18 00:18:09 +00:00
|
|
|
import ProductDownloader from '@hashicorp/react-product-downloader'
|
|
|
|
import Head from 'next/head'
|
2020-03-30 17:30:56 +00:00
|
|
|
import HashiHead from '@hashicorp/react-head'
|
2020-01-18 00:18:09 +00:00
|
|
|
|
|
|
|
export default function DownloadsPage({ downloadData }) {
|
2020-04-22 20:27:34 +00:00
|
|
|
const changelogUrl = CHANGELOG_URL.length
|
|
|
|
? CHANGELOG_URL
|
|
|
|
: `https://github.com/hashicorp/vault/blob/v${VERSION}/CHANGELOG.md`
|
2020-01-18 00:18:09 +00:00
|
|
|
return (
|
|
|
|
<div id="p-downloads" className="g-container">
|
2020-03-30 17:30:56 +00:00
|
|
|
<HashiHead is={Head} title="Downloads | Vault by Hashicorp" />
|
2020-01-18 00:18:09 +00:00
|
|
|
<ProductDownloader
|
|
|
|
product="Vault"
|
|
|
|
version={VERSION}
|
|
|
|
downloads={downloadData}
|
2020-04-22 20:27:34 +00:00
|
|
|
changelog={changelogUrl}
|
2020-01-18 00:18:09 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-03-16 18:56:44 +00:00
|
|
|
export async function getStaticProps() {
|
2020-01-18 00:18:09 +00:00
|
|
|
return fetch(`https://releases.hashicorp.com/vault/${VERSION}/index.json`)
|
2020-04-22 20:27:34 +00:00
|
|
|
.then((r) => r.json())
|
|
|
|
.then((r) => {
|
2020-01-18 00:18:09 +00:00
|
|
|
// TODO: restructure product-downloader to run this logic internally
|
|
|
|
return r.builds.reduce((acc, build) => {
|
|
|
|
if (!acc[build.os]) acc[build.os] = {}
|
|
|
|
acc[build.os][build.arch] = build.url
|
|
|
|
return acc
|
|
|
|
}, {})
|
|
|
|
})
|
2020-04-22 20:27:34 +00:00
|
|
|
.then((r) => ({ props: { downloadData: r } }))
|
2020-03-13 22:42:56 +00:00
|
|
|
.catch(() => {
|
|
|
|
throw new Error(
|
|
|
|
`--------------------------------------------------------
|
|
|
|
Unable to resolve version ${VERSION} on releases.hashicorp.com from link
|
|
|
|
<https://releases.hashicorp.com/vault/${VERSION}/index.json>. Usually this
|
|
|
|
means that the specified version has not yet been released. The downloads page
|
|
|
|
version can only be updated after the new version has been released, to ensure
|
|
|
|
that it works for all users.
|
|
|
|
----------------------------------------------------------`
|
|
|
|
)
|
|
|
|
})
|
2020-01-18 00:18:09 +00:00
|
|
|
}
|