Skip to content

Commit

Permalink
fix: allow - as delimiter in dep strings (#30)
Browse files Browse the repository at this point in the history
* Add workflow to test prebuilt files

* sudo

* allow - in dep strings
  • Loading branch information
AnActualEmerald authored Dec 27, 2023
1 parent 69a6cf2 commit aef20d7
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
maps
tools
items
deps: |
[email protected]
- run: echo ${{ steps.pub.outputs.url }}


Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/test_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Upload Prebuilt Zip

on:
push:
pull_request:
branches:
- main
workflow_dispatch:



jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: create test zip
run: |
sudo apt install zip
echo "{ \"namespace\": \"GreenTF\", \"name\": \"test\", \"description\": \"Test\", \"version_number\": \"1.${{ github.run_number }}.0\", \"dependencies\": [], \"website_url\": \"https://greenboi.me\" }" >> manifest.json
zip test.zip ./*
- id: pub
uses: ./
with:
namespace: GreenTF
name: Test
dev: true
token: ${{ secrets.TS_KEY }}
description: |
The FitnessGram Pacer test is a multistage aerobic capacity test that progressively gets more difficult as it continues.
The 20 meter Pacer test will begin in 30 seconds.
Line up at the start. The running speed starts slowly, but gets faster each minute after you hear this signal *boop*.
A single lap should be completed each time you hear this sound *ding*. Remember to run in a straight line, and run as long as possible.
The second time you fail to complete a lap before the sound, your test is over. The test will begin on the word start.
On your mark, get ready, start.
version: v1.${{ github.run_number }}.0
community: riskofrain2
repo: thunderstore.dev
wrap: mods
website: "https://greenboi.me"
categories: |
mods
maps
tools
items
deps: |
GreenTF-Test-0.130.0
file: ./test.zip
- run: echo ${{ steps.pub.outputs.url }}

51 changes: 29 additions & 22 deletions cfg_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ const tstore = TOML.parse(await Deno.readTextFile("./thunderstore.toml"));

const namespace = Deno.env.get("TS_NAMESPACE");
const name = Deno.env.get("TS_NAME");
const version = Deno.env.get("TS_VERSION").replace(/v/g, '');
const version = Deno.env.get("TS_VERSION").replace(/v/g, "");
const desc = Deno.env.get("TS_DESC").substring(0, 256); //truncate overlong descriptions
const homepage = Deno.env.get("TS_WEBSITE");
const categories = Deno.env.get("TS_CATEGORIES").replace(/\s/g, ','); //support comma and new-line delimiters
const deps = Deno.env.get("TS_DEPS").replace(/\n/g, ' ');
const categories = Deno.env.get("TS_CATEGORIES").replace(/\s/g, ","); //support comma and new-line delimiters
const deps = Deno.env.get("TS_DEPS").replace(/\n/g, " ");
const community = Deno.env.get("TS_COMMUNITY");
const nsfw = Deno.env.get("TS_NSFW");
const wrap = Deno.env.get("TS_WRAP");
const repo = Deno.env.get("TS_REPO");

const re = /([a-zA-Z_0-9]*-[a-zA-Z_0-9]*)[\-@](\d+\.\d+\.\d+)/;

//these should be set already but we're rewriting the whole file anyways
tstore.package.namespace = namespace;
Expand All @@ -26,45 +27,51 @@ tstore.publish.communities = [community];
tstore.build.copy[0].target = wrap;
tstore.package.dependencies = {};

tstore.publish.repository = repo ?? "https://thunderstore.io"

tstore.publish.repository = repo ?? "https://thunderstore.io";

//check for optional inputs
if (homepage && homepage !== "") {
tstore.package.websiteUrl = homepage;
} else {
tstore.package.websiteUrl = `${Deno.env.get("GITHUB_SERVER_URL")}/${Deno.env.get("GITHUB_REPOSITORY")}`;
tstore.package.websiteUrl = `${Deno.env.get(
"GITHUB_SERVER_URL"
)}/${Deno.env.get("GITHUB_REPOSITORY")}`;
}

if (nsfw && nsfw === "true" ) {
tstore.package.containsNsfwContent = true
if (nsfw && nsfw === "true") {
tstore.package.containsNsfwContent = true;
}

if (categories && categories !== "") {
console.log(`::debug::Parsing categories: ${categories}`);
tstore.publish.categories[community] = categories.split(',')
.filter(e => e) //only keep truthy elements
.map(e=> e.toLowerCase().trim());
tstore.publish.categories[community] = categories
.split(",")
.filter((e) => e) //only keep truthy elements
.map((e) => e.toLowerCase().trim());
}

if (deps && deps !== "") {
console.log("::debug::Parsing dependencies: ", deps.split(" "));
const p = {};
for (let d of deps.split(' ')) {
if(!d)
for (let d of deps.split(" ")) {
if (!d) {
console.log("::warn::Empty dependency", d);
continue;
if (!d.includes('@')) {
console.log("Malformed dependency at ", d);
Deno.exit(-1);
}

const parts = d.split('@');
p[parts[0]] = parts[1];

const parts = d.match(re);
if (parts) {
console.log("::debug::Parts:", parts);
p[parts[1]] = parts[2];
} else {
console.log("::error::Malformed dependency at ", d);
Deno.exit(1);
}
}
console.log(p);

console.log("::debug:: Built depencendies:", p);
tstore.package.dependencies = p;
}


//write config file back to disk
Deno.writeTextFile("./thunderstore.toml", TOML.stringify(tstore));
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function configure(){
echo "Init tcli config"
tcli init --package-name ${TS_NAME} --package-namespace ${TS_NAMESPACE} --package-version ${TS_VERSION#v}

echo $(deno run --allow-net --allow-env --allow-read --allow-write cfg_edit.js)
deno run --allow-net --allow-env --allow-read --allow-write cfg_edit.js

echo "Done config edit"
echo
Expand Down

0 comments on commit aef20d7

Please sign in to comment.