11const axios = require ( 'axios' ) ;
22const bytes = require ( 'bytes' ) ;
33// Define constant
4- const LINUX_GENERIC_X86 = 'Linux Generic(x86, 64-bit)' ;
5- const LINUX_GENERIC_ARM = 'Linux Generic(ARM, 64-bit)' ;
6- const MAC_X86 = 'macOS (x86, 64-bit)' ;
7- const MAC_ARM = 'macOS (ARM, 64-bit)' ;
4+ const LINUX_GENERIC_X86 = 'Linux Generic (x86, 64-bit)' ;
5+ const LINUX_GENERIC_ARM = 'Linux Generic (ARM, 64-bit)' ;
6+ const MAC_X86 = 'Mac Intel Chip (x86, 64-bit)' ;
7+ const MAC_ARM = 'Mac Apple Chip (ARM, 64-bit)' ;
88const GITHUB_DOWNLOAD = 'https://github.com/datafuselabs/databend/releases/download' ;
99const GITHUB_REPO = 'https://api.github.com/repos/datafuselabs/databend' ;
1010const DATABEND_RELEASES = 'https://repo.databend.rs/databend/releases.json' ;
@@ -22,15 +22,15 @@ module.exports = function fetchDatabendReleasesPlugin() {
2222 const { data : releasesList } = await axios . get ( DATABEND_RELEASES ) ;
2323 const { data : repoResource } = await axios . get ( GITHUB_REPO ) ;
2424 // Preprocessing data, Just part of it
25- let releases = releasesList ?. filter ( release => release . assets ?. length ) . slice ( 0 , 21 ) ;
25+ const releases = releasesList ?. filter ( release => release . assets ?. length ) . slice ( 0 , 21 ) ;
2626 const processedData = releases . map ( release => {
27- let afterFilterAssets =
28- release . assets
29- . filter ( asset => ! / l i n u x - g n u | t e s t s u i t e s | s h a 2 5 6 s u m s | \. d e b / . test ( asset . name ) )
27+ const filterAssets = namesToMatch ( release ) ;
28+ const afterProcessedAssets =
29+ filterAssets
3030 . map ( asset => {
31- let isApple = asset . name . includes ( 'apple' ) ;
32- let isAarch64 = asset . name . includes ( 'aarch64' ) ;
33- let osTypeDesc = isApple
31+ const isApple = asset . name . includes ( 'apple' ) ;
32+ const isAarch64 = asset . name . includes ( 'aarch64' ) ;
33+ const osTypeDesc = isApple
3434 ? ( isAarch64 ? MAC_ARM : MAC_X86 )
3535 : ( isAarch64 ? LINUX_GENERIC_ARM : LINUX_GENERIC_X86 ) ;
3636 return {
@@ -54,13 +54,27 @@ module.exports = function fetchDatabendReleasesPlugin() {
5454 return {
5555 ...release ,
5656 originAssets : release . assets ,
57- assets : afterFilterAssets ,
57+ assets : afterProcessedAssets ,
5858 filterBody : release . body
5959 . replace ( IGNORE_TEXT , '' )
6060 . replace ( REG , REPLACE_TEXT )
6161 . replace ( / @ ( \w + ) / g, '**@$1**' )
6262 }
6363 } ) ;
64+ // name match list
65+ function namesToMatch ( release ) {
66+ const { assets, tag_name } = release ;
67+ const namesDisplayList = [
68+ `databend-${ tag_name } -aarch64-apple-darwin.tar.gz` ,
69+ `databend-${ tag_name } -x86_64-apple-darwin.tar.gz` ,
70+ `databend-${ tag_name } -aarch64-unknown-linux-musl.tar.gz` ,
71+ `databend-${ tag_name } -x86_64-unknown-linux-gnu.tar.gz`
72+ ] ;
73+ const filteredAssets = assets ?. filter ( item => {
74+ return namesDisplayList ?. includes ( item ?. name ) ;
75+ } ) ;
76+ return filteredAssets ;
77+ }
6478 // Set global data
6579 setGlobalData ( { releasesList : processedData , repoResource, stargazersCount : repoResource . stargazers_count } ) ;
6680 } ,
0 commit comments