From b2917bcb0448b1eb43c2eee4a4d1c091f1d36fef Mon Sep 17 00:00:00 2001 From: Denis Melnik Date: Thu, 18 Jul 2024 18:24:41 +0300 Subject: [PATCH] fix: docs cli download link (#859) ## What Right now in the docs, the list of CLI versions relies on specific release order and sensitive to the changes in the structure of CLI github release. After this change, it still depends on it (by name) but the order no longer matters. Incorrect link in the docs: ```html Windows-x64 ``` --------- Co-authored-by: Vadim Kharin --- docs/index.js | 44 +++++++++++++++++++++++++++++++++----------- package.json | 2 +- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/docs/index.js b/docs/index.js index 72aa77540..136757525 100644 --- a/docs/index.js +++ b/docs/index.js @@ -342,7 +342,6 @@ const createAutomatedDocs = async () => { }; const createDownloadPage = async () => { - let links = []; const RequestOptions = { url: 'https://api.github.com/repos/codefresh-io/cli/releases/latest', headers: { @@ -351,10 +350,37 @@ const createDownloadPage = async () => { json: true, }; try { - const res = await rp(RequestOptions); - _.forEach(res.assets, ((asset) => { - links.push(asset.browser_download_url); - })); + // response example https://docs.github.com/en/rest/releases/releases#get-the-latest-release + const { assets = [] } = await rp(RequestOptions); + + const getDownloadUrlFromAssets = (nameRegex) => assets.find((a) => a.name.match(nameRegex))?.browser_download_url; + const downloadLinks = [ + { + label: 'Alpine-x64', + downloadUrl: getDownloadUrlFromAssets(/alpine-x64/), + }, + { + label: 'Linux-x64', + downloadUrl: getDownloadUrlFromAssets(/linux-x64/), + }, + { + label: 'Macos-x64', + downloadUrl: getDownloadUrlFromAssets(/macos-x64/), + }, + { + label: 'Windows-x64', + downloadUrl: getDownloadUrlFromAssets(/win-x64/), + }, + { + label: 'Alpine-arm64', + downloadUrl: getDownloadUrlFromAssets(/alpine-arm64/), + }, + { + label: 'Linux-arm64', + downloadUrl: getDownloadUrlFromAssets(/linux-arm64/), + }, + ]; + const commandFilePath = path.resolve(baseDir, './installation/download.md'); const finalContent = '+++\n' + @@ -368,12 +394,8 @@ const createDownloadPage = async () => { 'and download the binary that matches your operating system.
\n' + 'We currently support the following OS:
\n' + ' \n' + '\n' + 'After downloading the binary, untar or unzip it and your are good to go.
\n' + diff --git a/package.json b/package.json index fdcc11027..1576291c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.87.4", + "version": "0.87.5", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,