3 // this may need customizations between packages
5 macos: /\b(mac|darwin|iPhone|iOS|iPad)/i,
7 win: /\b(win|microsoft|msft)/i,
13 amd64: /(amd64|x64|[_\-]64)/i,
14 x86: /\b(x86)(?![_\-]64)/i,
15 ppc64le: /\b(ppc64le)/i,
16 ppc64: /\b(ppc64)\b/i,
18 arm64: /\b(arm64|arm)/i,
19 armv7l: /\b(armv?7l)/i,
20 armv6l: /\b(armv?6l)/i,
30 tar: /\.(tar(\.?(gz)?)|tgz)/i,
35 * Gets the releases for 'ripgrep'. This function could be trimmed down and made
36 * for use with any github release.
39 * @param {string} owner
40 * @param {string} repo
41 * @returns {PromiseLike<any> | Promise<any>}
43 function getAllReleases(request, owner = 'BurntSushi', repo = 'ripgrep') {
45 return Promise.reject('missing owner for repo');
48 return Promise.reject('missing repo name');
51 url: `https://api.github.com/repos/${owner}/${repo}/releases`,
54 const gHubResp = resp.body;
60 gHubResp.forEach((release) => {
61 release['assets'].forEach((asset) => {
62 // set the primary download to the first of the releases
63 if (all.download === '') {
64 all.download = asset['browser_download_url'];
67 const name = asset['name'];
69 Object.keys(osMap).find((regKey) => {
70 name.match(osMap[regKey]);
72 const arch = Object.keys(archMap).find((regKey) =>
73 name.match(archMap[regKey])
77 Object.keys(fileExtMap).find((regKey) => {
78 const match = name.match(fileExtMap[regKey]);
87 download: asset['browser_download_url'],
88 date: release['published_at'],
89 version: release['tag_name'],
90 lts: !release['prerelease'],
102 module.exports = getAllReleases;
104 if (module === require.main) {
105 getAllReleases(require('@root/request'), 'BurntSushi', 'ripgrep').then(
107 console.log(JSON.stringify(all, null, 2));