Skip to content

Commit e74257a

Browse files
authored
fix: bundles (#82)
1 parent f6a1e4a commit e74257a

File tree

101 files changed

+918
-598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+918
-598
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Check Bundles"
2+
on:
3+
push:
4+
paths:
5+
- oneclient/**
6+
workflow_dispatch:
7+
8+
jobs:
9+
pnpm:
10+
name: install dependencies (pnpm)
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Git checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup pnpm
17+
uses: pnpm/action-setup@v2
18+
19+
- name: Use Node.js ${{ env.NODE_VERSION }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ env.NODE_VERSION }}
23+
cache: "pnpm"
24+
25+
- name: Install node dependencies
26+
run: pnpm i
27+
28+
CheckBundles:
29+
name: Check Bundles are correctly formatted
30+
needs: [pnpm]
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Git checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup pnpm
37+
uses: pnpm/action-setup@v2
38+
39+
- name: Use Node.js ${{ env.NODE_VERSION }}
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: ${{ env.NODE_VERSION }}
43+
cache: "pnpm"
44+
45+
- name: Install node dependencies
46+
run: pnpm i
47+
48+
- name: Check Bundles
49+
run: pnpm check
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Generate Bundles"
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
GenerateBundles:
7+
name: generate Bundles
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Git checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Allow running the script
14+
run: chmod +x ./oneclient/generate-bundles.sh
15+
16+
- name: Generate Bundles
17+
run: ./oneclient/generate-bundles.sh
18+
19+
- name: Commit and push the generated bundles
20+
run: |
21+
git config --global user.name "Bundle Updater[bot]"
22+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
23+
git add .
24+
git commit -m "chore(generate-bundles)" || echo "No changes to commit"
25+
git push origin main
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Update and Generate Bundles"
2+
on:
3+
push:
4+
paths:
5+
- oneclient/**
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
UpdateAndGenerateBundles:
12+
name: Update and Generate Bundles
13+
runs-on: ubuntu-latest
14+
if: ${{ 'push' == github.event_name && 'main' == github.ref_name && '438157081' == github.repository_id }}
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Allow running the scripts
20+
run: |
21+
chmod +x ./oneclient/update-bundles.sh
22+
chmod +x ./oneclient/generate-bundles.sh
23+
24+
- name: Update Bundles
25+
run: ./oneclient/update-bundles.sh
26+
27+
- name: Generate Bundles
28+
run: ./oneclient/generate-bundles.sh
29+
30+
- name: Commit and push the updated and generated bundles
31+
run: |
32+
git config --global user.name "Bundle Updater[bot]"
33+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
34+
git add .
35+
git commit -m "chore(update-generate-bundles)" || echo "No changes to commit"
36+
git push origin main

.github/workflows/UpdateBundles.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
name: 'Update Bundles'
1+
name: "Update Bundles"
22
on:
3-
push:
4-
paths:
5-
- oneclient/**
6-
branches:
7-
- main
83
workflow_dispatch:
94

105
jobs:
116
UpdateBundles:
127
name: Update Bundles
138
runs-on: ubuntu-latest
14-
if: ${{ 'push' == github.event_name && 'main' == github.ref_name && '438157081' == github.repository_id }}
159
steps:
1610
- name: Git checkout
1711
uses: actions/checkout@v4
@@ -28,4 +22,4 @@ jobs:
2822
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
2923
git add .
3024
git commit -m "chore(update-bundles)" || echo "No changes to commit"
31-
git push origin main
25+
git push origin main

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ replay_*.log
4141

4242
oneclient/Linux-64-bit-x86.zip
4343
oneclient/packwiz
44+
packwiz.exe
45+
node_modules

oneclient/bundles.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
]
3131
}
3232
}
33-
}
33+
}

oneclient/check.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
const fs = require("fs");
2+
const toml = require("@iarna/toml");
3+
4+
const errors = [];
5+
6+
function checkMod(file) {
7+
const fileData = fs.readFileSync(file, "utf-8");
8+
const parsed = toml.parse(fileData);
9+
10+
if (!parsed.id) {
11+
errors.push(`${file} doesn't have an id?`);
12+
return null;
13+
}
14+
15+
if (!parsed.filename || !parsed.filename.endsWith(".jar")) {
16+
errors.push(`${file} invalid mod name`);
17+
return null;
18+
}
19+
20+
if (!parsed.download?.url) {
21+
errors.push(`${file} doesn't have a download url?`);
22+
return null;
23+
}
24+
25+
if (!parsed.update && !parsed.overrides) {
26+
errors.push(`${file} doesn't have overrides...`);
27+
return parsed.id;
28+
}
29+
30+
if (parsed.update?.modrinth?.version) {
31+
const modVersion = parsed.update.modrinth.version;
32+
const split = parsed.download.url.split("/");
33+
if (split[split.length - 2] !== modVersion) {
34+
errors.push(`${file} has a bad download modrinth url. Please fix`);
35+
return parsed.id;
36+
}
37+
}
38+
39+
return parsed.id;
40+
}
41+
42+
function checkBundle(bundlePath, bundle) {
43+
const mods = fs.readdirSync(`${bundlePath}/mods`);
44+
const modIds = [];
45+
for (const mod of mods) {
46+
if (!mod.endsWith(".toml")) {
47+
errors.push(
48+
`${bundlePath} - Will not work because it contains a jar file`
49+
);
50+
return;
51+
}
52+
53+
const path = `${bundlePath}/mods/${mod}`;
54+
const modId = checkMod(path);
55+
if (!modId) continue;
56+
if (modId.toLowerCase() === bundle.toLowerCase()) {
57+
errors.push(
58+
`${path} uses the defualt mod id. This is not recommended but not blocked`
59+
);
60+
}
61+
if (modIds.includes(modId)) {
62+
errors.push(`${path} has a duplicate mod id`);
63+
} else {
64+
modIds.push(modId);
65+
}
66+
}
67+
}
68+
69+
const versions = fs.readdirSync("./oneclient/mrpacks/");
70+
for (const version of versions) {
71+
const bundles = fs.readdirSync(`./oneclient/mrpacks/${version}`);
72+
for (const bundle of bundles) {
73+
checkBundle(`./oneclient/mrpacks/${version}/${bundle}`, bundle);
74+
}
75+
}
76+
77+
if (errors.length > 0) {
78+
errors.forEach((error) => console.log(error));
79+
throw new Error("Something wen't wrong");
80+
}

oneclient/format.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,54 @@
11
ok so here's the modpack structure:
2+
currently in <https://github.com/Polyfrost/DataStorage>
23

3-
Each packwiz instance in `oneclient/mrpacks/${mcVersion}-${mcLoader}/${Category Name}`
4-
5-
The format is mrpack + the following:
4+
`oneclient/mrpacks/${mcVersion}-${mcLoader}/${Category Name}`
65

6+
the format is mrpack + the following:
77
Additional fields:
8-
98
`enabled: boolean` - whether it is enabled by default in oneclient
10-
119
`id: string` (can just be the category name but lowercase)
12-
1310
`category: string`
14-
1511
`polyFormat: number` (1)
16-
1712
`updateUrl: string`
1813

19-
2014
individual file / package additional fields:
21-
2215
`id: string` - the modrinth id of the mod, or a normal id if not on modrinth
23-
24-
`enabled: boolean` - whether it is enabled by default __when the category is selected__ - `true` by default
25-
16+
`enabled: boolean` - whether it is enabled by default **when the category is selected** - `true` by default
2617
`hidden: boolean` - whether oneclient should hide the mod
2718

28-
`overrides: object` - Visual overrides for mod name, author, description, and icon. Author is a string array and icon takes a URL
29-
3019
1.8.9 Forge
20+
3121
- Performance
3222
- QoL
3323
- HUD
3424
- SkyBlock
3525
- PvP
3626
- Utility
3727

38-
1.21.1 Fabric
28+
1.21.1 Fabric
29+
3930
- Performance
4031
- QoL
4132
- HUD
42-
- SkyBlock
4333
- PvP
4434
- Utility
4535

46-
1.21.5 Fabric
36+
1.21.5 Fabric
37+
4738
- Performance
4839
- QoL
4940
- HUD
5041
- SkyBlock
5142
- PvP
5243
- Utility
5344

54-
1.21.8 Fabric
45+
1.21.8 Fabric
46+
5547
- Performance
5648
- QoL
5749
- HUD
5850
- SkyBlock
5951
- PvP
6052
- Utility
53+
54+
Modrinth API won't accpet a mod download url that has it's version name in it and not the version id. Please run the check.js file to check for this stuff and other issues

oneclient/generate-bundles.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
5+
URL="https://nightly.link/Polyfrost/packwiz/workflows/go/main/Linux%2064-bit%20x86.zip"
6+
ZIP="Linux-64-bit-x86.zip"
7+
8+
echo "Downloading and setting up packwiz"
9+
wget -O "$ZIP" "$URL" && unzip -o "$ZIP" && chmod +x packwiz
10+
mkdir -p generated
11+
12+
for version in mrpacks/*; do
13+
[ -d "$version" ] || continue
14+
parsed="${version#mrpacks/}"
15+
for bundle in "$version"/*; do
16+
[ -d "$bundle" ] || continue
17+
echo "Bundling $bundle"
18+
(cd "$bundle" && ../../../packwiz modrinth export)
19+
export_files=("$bundle"/*.mrpack)
20+
if [[ ${#export_files[@]} -ne 1 ]] || [[ ! -f "${export_files[0]}" ]]; then
21+
echo "Error: Expected 1 .mrpack file in '$bundle', but found ${#export_files[@]}. Skipping." >&2
22+
continue
23+
fi
24+
export_file="${export_files[0]}"
25+
26+
name=$(basename "$bundle")
27+
name="${name,,}"
28+
echo "Moving '$export_file' to 'generated/$name-$parsed.mrpack'"
29+
mv "$export_file" "generated/$name-$parsed.mrpack"
30+
done
31+
done
-71.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)