create gitea from github
[webi-installers/.git] / _common / gitea.js
diff --git a/_common/gitea.js b/_common/gitea.js
new file mode 100644 (file)
index 0000000..425d7d7
--- /dev/null
@@ -0,0 +1,31 @@
+'use strict';
+
+var ghRelease = require('./github.js');
+
+/**
+ * Gets the releases for 'ripgrep'. This function could be trimmed down and made
+ * for use with any github release.
+ *
+ * @param request
+ * @param {string} owner
+ * @param {string} repo
+ * @returns {PromiseLike<any> | Promise<any>}
+ */
+function getAllReleases(request, owner, repo, baseurl) {
+  if (!baseurl) {
+    return Promise.reject('missing baseurl');
+  }
+  return ghRelease(request, owner, repo, baseurl + '/api/v1').then(function (all) {
+    return all;
+  });
+}
+
+module.exports = getAllReleases;
+
+if (module === require.main) {
+  getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
+    function (all) {
+      console.log(JSON.stringify(all, null, 2));
+    }
+  );
+}