Skip to content

Commit b2917bc

Browse files
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 <a href="https://github.com/codefresh-io/cli/releases/download/v0.87.3/codefresh-v0.87.3-macos-x64.tar.gz" target="_blank">Windows-x64</a> ``` --------- Co-authored-by: Vadim Kharin <vadim.kharin@codefresh.io>
1 parent 9e55ce6 commit b2917bc

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

docs/index.js

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ const createAutomatedDocs = async () => {
342342
};
343343

344344
const createDownloadPage = async () => {
345-
let links = [];
346345
const RequestOptions = {
347346
url: 'https://api.github.com/repos/codefresh-io/cli/releases/latest',
348347
headers: {
@@ -351,10 +350,37 @@ const createDownloadPage = async () => {
351350
json: true,
352351
};
353352
try {
354-
const res = await rp(RequestOptions);
355-
_.forEach(res.assets, ((asset) => {
356-
links.push(asset.browser_download_url);
357-
}));
353+
// response example https://docs.github.com/en/rest/releases/releases#get-the-latest-release
354+
const { assets = [] } = await rp(RequestOptions);
355+
356+
const getDownloadUrlFromAssets = (nameRegex) => assets.find((a) => a.name.match(nameRegex))?.browser_download_url;
357+
const downloadLinks = [
358+
{
359+
label: 'Alpine-x64',
360+
downloadUrl: getDownloadUrlFromAssets(/alpine-x64/),
361+
},
362+
{
363+
label: 'Linux-x64',
364+
downloadUrl: getDownloadUrlFromAssets(/linux-x64/),
365+
},
366+
{
367+
label: 'Macos-x64',
368+
downloadUrl: getDownloadUrlFromAssets(/macos-x64/),
369+
},
370+
{
371+
label: 'Windows-x64',
372+
downloadUrl: getDownloadUrlFromAssets(/win-x64/),
373+
},
374+
{
375+
label: 'Alpine-arm64',
376+
downloadUrl: getDownloadUrlFromAssets(/alpine-arm64/),
377+
},
378+
{
379+
label: 'Linux-arm64',
380+
downloadUrl: getDownloadUrlFromAssets(/linux-arm64/),
381+
},
382+
];
383+
358384
const commandFilePath = path.resolve(baseDir, './installation/download.md');
359385
const finalContent =
360386
'+++\n' +
@@ -368,12 +394,8 @@ const createDownloadPage = async () => {
368394
'and download the binary that matches your operating system.<br>\n' +
369395
'We currently support the following OS: <br>\n' +
370396
'<ul>\n' +
371-
' <li><a href=' + links[0] + ' target="_blank">Alpine-arm64</a></li>\n' +
372-
' <li><a href=' + links[1] + ' target="_blank">Alpine-x64</a></li>\n' +
373-
' <li><a href=' + links[2] + ' target="_blank">Linux-arm64</a></li>\n' +
374-
' <li><a href=' + links[3] + ' target="_blank">Linux-x64</a></li>\n' +
375-
' <li><a href=' + links[4] + ' target="_blank">Macos-x64</a></li>\n' +
376-
' <li><a href=' + links[5] + ' target="_blank">Windows-x64</a></li>\n' +
397+
downloadLinks.map(({ label, downloadUrl = 'https://github.com/codefresh-io/cli/releases' }) =>
398+
` <li><a href='${downloadUrl}' target="_blank">${label}</a></li>`).join('\n') +
377399
'</ul> \n' +
378400
'\n' +
379401
'After downloading the binary, untar or unzip it and your are good to go.<br>\n' +

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.87.4",
3+
"version": "0.87.5",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)