refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / _common / gitea.js
1 'use strict';
2
3 var ghRelease = require('./github.js');
4
5 /**
6  * Gets the releases for 'ripgrep'. This function could be trimmed down and made
7  * for use with any github release.
8  *
9  * @param request
10  * @param {string} owner
11  * @param {string} repo
12  * @returns {PromiseLike<any> | Promise<any>}
13  */
14 function getAllReleases(request, owner, repo, baseurl) {
15   if (!baseurl) {
16     return Promise.reject('missing baseurl');
17   }
18   return ghRelease(request, owner, repo, baseurl + '/api/v1').then(function (
19     all
20   ) {
21     return all;
22   });
23 }
24
25 module.exports = getAllReleases;
26
27 if (module === require.main) {
28   getAllReleases(
29     require('@root/request'),
30     'coolaj86',
31     'go-pathman',
32     'https://git.coolaj86.com'
33   ).then(
34     //getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
35     function (all) {
36       console.info(JSON.stringify(all, null, 2));
37     }
38   );
39 }