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'];
68 const os = Object.keys(osMap).find(regKey => {
69 name.match(osMap[regKey]);
71 const arch = Object.keys(archMap)
72 .find(regKey => name.match(archMap[regKey]));
75 Object.keys(fileExtMap).find(regKey => {
76 const match = name.match(fileExtMap[regKey]);
85 download: asset['browser_download_url'],
86 date: release['published_at'],
87 version: release['tag_name'],
88 lts: !release['prerelease'],
100 module.exports = getAllReleases;
102 if (module === require.main) {
103 getAllReleases(require('@root/request'), 'BurntSushi', 'ripgrep').then(function(all) {
104 console.log(JSON.stringify(all, null, 2));