Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

Commit 506a538

Browse files
authored
Use webapp client (#26)
* this config option * wee web app client stuff * add app version flag, icon to the POST * Update README.md * Update config.nims * fix some more things * more verbose errors
1 parent 3053b2b commit 506a538

29 files changed

+252
-861
lines changed

.DS_Store

6 KB
Binary file not shown.

.vscode/tasks.json

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"label": "Compile",
88
"type": "shell",
9-
"command": "nimble build",
9+
"command": "nimble build -d:ssl",
1010
"problemMatcher": [],
1111
"group": {
1212
"kind": "build",
@@ -21,7 +21,6 @@
2121
"clear": false
2222
}
2323
},
24-
2524
{
2625
"label": "Install",
2726
"type": "shell",
@@ -38,26 +37,6 @@
3837
"showReuseMessage": true,
3938
"clear": false
4039
}
41-
},
42-
43-
{
44-
"label": "Run Test",
45-
"type": "shell",
46-
"command": "lovebrew build",
47-
"options": { "cwd": "test" },
48-
"group": {
49-
"kind": "build",
50-
"isDefault": true
51-
},
52-
"problemMatcher": [],
53-
"presentation": {
54-
"echo": true,
55-
"reveal": "always",
56-
"focus": true,
57-
"panel": "shared",
58-
"showReuseMessage": true,
59-
"clear": false
60-
}
6140
}
6241
]
6342
}

README.md

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,10 @@
44

55
The easiest way to "install" LÖVEBrew is from the [releases page](https://github.com/TurtleP/lovebrew/releases). Download the respective platform's release and put it in the following directory for your operating system:
66

7-
- Windows: `%appdata%/lovebrew/bin`
8-
- macOS/Linux: `~/.config/lovebrew/bin`
7+
- Windows: `%appdata%/lovebrew/`
8+
- macOS/Linux: `~/.config/lovebrew/`
99
- Create this directory and add it to your PATH!
1010

11-
## Dependencies
12-
13-
Some things are required to be installed/added for LÖVEBrew to function properly. Specifically install these packages [from devkitpro-pacman](https://devkitpro.org/wiki/devkitPro_pacman):
14-
15-
Building for Nintendo 3DS:
16-
17-
- `tex3ds`
18-
19-
One binary not provided by devkitpro-pacman:
20-
21-
- [`hbupdater`](https://github.com/TurtleP/hbupdater)
22-
23-
## Building a Project
24-
25-
LÖVEBrew will look for the LÖVE Potion binaries by default in the OS configuration directory. However, you _can_ override this setting inside the config file and it will search relative to the project's root. The config directory is at the following locations:
26-
27-
- Windows: `%appdata%/lovebrew`
28-
- Linux and macOS: `~/.config/lovebrew`
29-
3011
## Options
3112

3213
```

config.nims

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ when defined(Windows) or defined(Linux):
99
switch("passL", "-s")
1010
# Change to release mode
1111
switch("d", "release")
12+
switch("d", "ssl")

lovebrew.nimble

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.6.0"
3+
version = "0.7.0"
44
author = "TurtleP"
55
description = "LÖVE Potion Game Distribution Helper"
66
license = "MIT"
@@ -12,6 +12,6 @@ binDir = "dist"
1212
# Dependencies
1313

1414
requires "nim >= 1.6.0"
15-
requires "zippy"
16-
requires "parsetoml"
1715
requires "cligen"
16+
requires "toml_serialization"
17+
requires "zippy"

res/icon.ico

-18.4 KB
Binary file not shown.

res/icon/icon.o

-18.7 KB
Binary file not shown.

res/icon/icon.rc

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

src/client.nim

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import std/[asyncdispatch, httpclient]
2+
import tables
3+
import strutils
4+
import strformat
5+
6+
import logger
7+
8+
import zippy/ziparchives
9+
10+
const PostUrl = "https://www.bundle.lovebrew.org/"
11+
var dataEndPoint = "/data?title=$title&description=$description&author=$author&version=$version&mode=$mode&app_version=$app_version"
12+
13+
proc asyncProc(endpoint: string, zipFilePath: string,
14+
iconFilePath: string): Future[AsyncResponse] {.async.} =
15+
16+
var client = newAsyncHttpClient()
17+
var data = newMultipartData()
18+
19+
data.addFiles({"game": zipFilePath})
20+
21+
if not iconFilePath.isEmptyOrWhitespace:
22+
data.addFiles({"icon": iconFilePath})
23+
24+
return await client.post(endpoint, multipart = data)
25+
26+
proc sendData*(mode: string, app_version: string, metadata: Table[string, string],
27+
gameDir: string): (bool, string, string) =
28+
29+
if mode == "cafe" and parseInt(app_version) < 3:
30+
return (false, "", "Wii U is not supported on app versions < 3")
31+
32+
var copy = dataEndPoint
33+
for key, value in metadata.pairs():
34+
copy = copy.replace(&"${key}", value)
35+
36+
copy = copy.replace("$mode", mode)
37+
copy = copy.replace("$app_version", app_version)
38+
39+
var name = metadata["title"]
40+
41+
try:
42+
logger.info(&"Zipping {gameDir} to {name}.love")
43+
ziparchives.createZipArchive(&"{gameDir}/", &"{name}.love")
44+
except ZippyError as e:
45+
return (false, "", e.msg)
46+
47+
var extension = "3dsx"
48+
49+
case mode:
50+
of "hac":
51+
extension = "nro"
52+
of "cafe":
53+
extension = "wuhb"
54+
55+
var filename = &"{name}.{extension}"
56+
57+
try:
58+
let response = waitFor asyncProc(&"{PostUrl}{copy}", &"{name}.love", metadata["icon"])
59+
let content = waitFor response.body()
60+
61+
if response.code() == HttpCode(200):
62+
return (true, filename, content)
63+
else:
64+
return (false, "", content)
65+
except CatchableError as e:
66+
return (false, "", e.msg)
67+
68+
return (false, "", "failed to build")

0 commit comments

Comments
 (0)