Skip to content

Commit

Permalink
Merge pull request #1225 from Oganesson897/packwiz
Browse files Browse the repository at this point in the history
buildscript windows compatibility
  • Loading branch information
bruberu authored Jan 17, 2025
2 parents 0b6ebbd + efccf58 commit 561ba9b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ index.toml
*.log
*.txt
*.dll
*.exe

build/modlist.*
config/InvTweaks.cfg
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Special thanks to our volunteers:
- Science Demon • Questbook work, German translation and bug fixes

## Development Tips
> Please download [Packwiz](https://packwiz.infra.link/installation/) to the current directory manually.
> [Full Usage - Packwiz Tutorial](https://packwiz.infra.link/tutorials/creating/getting-started/)
- Add mod: `packwiz cf add <project name>` ([Full Usage](https://packwiz.infra.link/tutorials/creating/adding-mods/))
- Refresh Hash: `packwiz refresh`
Expand All @@ -82,7 +81,6 @@ Special thanks to our volunteers:
- Client only mod: [rewrite <mod>.pw.toml#side manually](https://packwiz.infra.link/reference/pack-format/mod-toml/#properties)

## Building the pack
1. Please download [Packwiz](https://packwiz.infra.link/installation/) to the current directory manually.
2. Run `pip install requests` first to install required package.
3. Run `python build/main.py`.
4. Check `buildOut` folder.
1. Run `pip install requests` first to install required package.
2. Run `python build/main.py`.
3. Check `buildOut` folder.
19 changes: 12 additions & 7 deletions build/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""build client & server bundles"""

import argparse
# if there is a problem with building, please let htmlcsjs know
import os
import sys
import shutil
Expand Down Expand Up @@ -49,7 +48,15 @@ def parse_args():

return parser.parse_args()

def packwiz():
if os.name == 'posix':
subprocess.run(['chmod', '+x', './packwiz'], check=True)
return './packwiz'
if os.name == 'nt':
return 'packwiz.exe'

basePath = os.path.normpath(os.path.realpath(__file__)[:-7] + "..")
packwizName = packwiz()

def build(args):
# Run questbook.py first
Expand All @@ -66,18 +73,17 @@ def build(args):
export_client_pack() # Client

if args.client:
return;
return

export_modlist()
export_server_pack()

def refresh():
subprocess.run(['chmod', '+x', './packwiz'], check=True)
subprocess.run(['./packwiz', 'refresh'], check=True)
subprocess.run([packwizName, 'refresh'], check=True)

def export_client_pack():
print("Client Pack Exporting")
subprocess.run(['./packwiz', 'curseforge', 'export', '-o', 'client.zip'], check=True)
subprocess.run([packwizName, 'curseforge', 'export', '-o', 'client.zip'], check=True)
shutil.copy('./client.zip', './buildOut/')
os.remove('./client.zip')
print("Client Pack Export Done")
Expand All @@ -103,15 +109,14 @@ def export_server_pack():

for file in ['launch.sh', 'forge-1.12.2-14.23.5.2860.jar', 'LICENSE', 'minecraft_server.1.12.2.jar']:
zipf.write(file, file)
os.remove(file)

os.chdir("../..")
shutil.move(f"build/server/{server_pack}", f"buildOut/{server_pack}")
print("Server Pack Export Done")

def export_modlist():
print("Modlist Exporting")
result = subprocess.run(['./packwiz', 'list'], capture_output=True, text=True).stdout.strip().split('\n')
result = subprocess.run([packwizName, 'list'], capture_output=True, encoding='utf-8').stdout.strip().split('\n')
with open(basePath + "/buildOut/modlist.html", "w") as file:
data = "<html><body><h1>Modlist</h1><ul>"
for mod in result:
Expand Down
Binary file added packwiz.exe
Binary file not shown.

0 comments on commit 561ba9b

Please sign in to comment.