~avery/public-inbox

compatibility-tools-manager: Add support for multiple compatibility layers and modularize into JSON v1 APPLIED

All future compatibility tools can be added to .JSON for support.

Hunter King (1):
  Add support for Roberta, Boxtron, modularize support

 src/releases.ts | 33 ++++++++++++++-------------------
 src/view.tsx    |  2 +-
 tools.json      |  6 ++++++
 3 files changed, 21 insertions(+), 20 deletions(-)
 create mode 100644 tools.json

-- 
2.34.2
#815261 .build.yml failed
compatibility-tools-manager/patches/.build.yml: FAILED in 19s

[Add support for multiple compatibility layers and modularize into JSON][0] from [~hunterking][1]

[0]: https://lists.sr.ht/~avery/public-inbox/patches/34392
[1]: mailto:hking0036@gmail.com

✗ #815261 FAILED compatibility-tools-manager/patches/.build.yml https://builds.sr.ht/~avery/job/815261
Thanks, pushed this patch and the previous one!

To git.sr.ht:~avery/compatibility-tools-manager
   2d80964..109b38a  main -> main
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~avery/public-inbox/patches/34392/mbox | git am -3
Learn more about email & git

[PATCH compatibility-tools-manager 1/1] Add support for Roberta, Boxtron, modularize support Export this patch

From: Hunter King <hking0036@gmail.com>

---
 src/releases.ts | 33 ++++++++++++++-------------------
 src/view.tsx    |  2 +-
 tools.json      |  6 ++++++
 3 files changed, 21 insertions(+), 20 deletions(-)
 create mode 100644 tools.json

diff --git a/src/releases.ts b/src/releases.ts
index 935be3f..06b44db 100644
--- a/src/releases.ts
+++ b/src/releases.ts
@@ -1,4 +1,5 @@
import { SMM } from '.';
import toolsJson from '../tools.json'

export interface Release {
  tag_name: string;
@@ -14,32 +15,26 @@ export interface Release {

let releasesCache: Release[] | undefined;

//Enumerate all Proton-GE Releases.
export const getGEReleases = async (smm: SMM) => {
  releasesCache = (await smm.Network.get(
    'https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases'
  )) as Release[];
  return releasesCache;
};

//Enumerate all Luxtorpeda releases.
export const getLuxReleases = async (smm: SMM) => {
  releasesCache = (await smm.Network.get(
    'https://api.github.com/repos/luxtorpeda-dev/luxtorpeda/releases'
  )) as Release[];
//Go through each tool in the JSON and scrape for releases.
export const scrapeReleases = async (smm: SMM, tool: String, url: String) => {
  releasesCache = (await smm.Network.get(url)) as Release[];
  
  //If the tool releases with only a version in front, then go ahead and staple the name on for clarity.
  for (var release of releasesCache){
    release['tag_name'] = "Luxtorpeda-" + release['tag_name'];
    if(release['tag_name'].charAt(0) === "v" ||  !(release['tag_name'].charAt(0).match(/[a-z]/i)) ){
      release['tag_name'] = tool + '-' + release['tag_name'];
    }
  }

  return releasesCache;
};
}

//Cache the releases of all supported tools.
export const getReleases = async(smm: SMM) => {
  if (!releasesCache){
    releasesCache = await getGEReleases(smm) as Release[];
    releasesCache = releasesCache.concat(( await getLuxReleases(smm) as Release[]));
  if(!releasesCache){
    releasesCache = [];
    for (let tool in toolsJson){
      releasesCache = releasesCache?.concat( await scrapeReleases(smm, tool, toolsJson[tool]) as Release[]);
    }
  }
  return releasesCache;
};
\ No newline at end of file
diff --git a/src/view.tsx b/src/view.tsx
index b11fa54..d8f2cb3 100644
--- a/src/view.tsx
+++ b/src/view.tsx
@@ -1,7 +1,7 @@
import { SMM } from '.';
import { getInstalledTools } from './get-tools';
import { installTool } from './install-tool';
import { getReleases} from './releases';
import { getReleases } from './releases';
import { removeTool } from './remove-tool';
import styles from './styles.css';
import { dcCreateElement, deleteAll, getCompatToolsDir } from './utils';
diff --git a/tools.json b/tools.json
new file mode 100644
index 0000000..7e9e341
--- /dev/null
+++ b/tools.json
@@ -0,0 +1,6 @@
{
    "Proton-GE": "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
    "Luxtorpeda": "https://api.github.com/repos/luxtorpeda-dev/luxtorpeda/releases",
    "Roberta": "https://api.github.com/repos/dreamer/roberta/releases",
    "Boxtron": "https://api.github.com/repos/dreamer/boxtron/releases"
}
\ No newline at end of file
-- 
2.34.2
compatibility-tools-manager/patches/.build.yml: FAILED in 19s

[Add support for multiple compatibility layers and modularize into JSON][0] from [~hunterking][1]

[0]: https://lists.sr.ht/~avery/public-inbox/patches/34392
[1]: mailto:hking0036@gmail.com

✗ #815261 FAILED compatibility-tools-manager/patches/.build.yml https://builds.sr.ht/~avery/job/815261
Thanks, pushed this patch and the previous one!

To git.sr.ht:~avery/compatibility-tools-manager
   2d80964..109b38a  main -> main