Skip to content

Commit 51b825d

Browse files
committed
Removed python scripts and updated editor script
1 parent c429f19 commit 51b825d

File tree

3 files changed

+31
-101
lines changed

3 files changed

+31
-101
lines changed

poki-sdk/editor/httpserver.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

poki-sdk/editor/poki.editor_script

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
local M = {}
22

3+
local POKI_ZIP = "poki.zip"
4+
5+
-- https://help.interfaceware.com/code/details/urlcode-lua
6+
local function urlencode(str)
7+
str = string.gsub (str, "([^0-9a-zA-Z !'()*._~-])", -- locale independent
8+
function (c) return string.format ("%%%02X", string.byte(c)) end)
9+
str = string.gsub (str, " ", "+")
10+
return str
11+
end
12+
313
local function poki_errors(config)
414
if not next(config.architectures) then
515
return "At least one architecture must be selected."
@@ -21,17 +31,34 @@ local poki_bundle_dialog = editor.ui.component(function(props)
2131
end)
2232

2333
local function bundle_poki(show_dialog)
34+
local project_title = editor.get("/game.project", "project.title")
35+
2436
local config = editor.bundle.config(show_dialog, "bundle.poki", poki_bundle_dialog, poki_errors)
2537
local js = config.architectures["js-web"]
2638
local wasm = config.architectures["wasm-web"]
2739
local output_subdir = (js and wasm and "universal-web") or (js and "js-web") or "wasm-web"
2840
local output_directory = editor.bundle.output_directory(show_dialog, output_subdir)
2941
local architectures = (js and wasm and "js-web,wasm-web") or (js and "js-web") or "wasm-web"
30-
editor.bundle.create(config, output_directory, {platform = "js-web", architectures = architectures})
42+
editor.bundle.create(config, output_directory, { platform = "js-web", architectures = architectures })
3143

32-
local port = 8000
33-
editor.execute("bash", "poki-sdk/editor/starthttpserver.sh", output_directory, tostring(port))
34-
--editor.browser("https://app.poki.dev/upload-defold?project=MYPROJECT&zipfile=http://127.0.0.1:" .. port .. "/poki.zip")
44+
-- zip bundle output directory
45+
zip.pack(POKI_ZIP, {
46+
{ output_directory .. "/" .. project_title, project_title }
47+
})
48+
49+
-- browse to poki uploader
50+
local urlfmt = "https://app.poki.dev/upload-defold?project=%s&zipfile=http://127.0.0.1:%s/poki/%s"
51+
local url = string.format(urlfmt, urlencode(project_title), http.server.port, POKI_ZIP)
52+
print("Opening", url)
53+
editor.browse(url)
54+
end
55+
56+
function M.get_http_server_routes()
57+
return {
58+
http.server.route("/poki/" .. POKI_ZIP, "GET", function(request)
59+
return http.server.external_file_response(POKI_ZIP)
60+
end)
61+
}
3562
end
3663

3764
function M.get_commands()

poki-sdk/editor/starthttpserver.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)