forked from CCBlueX/LiquidBounce
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.py
68 lines (56 loc) · 2.22 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
#
# Copyright (c) 2016 - 2023 CCBlueX
#
# LiquidBounce is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LiquidBounce is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
# Go through every folder and copy public folder to tmp folder with name of folder
import os
import shutil
# Make function that builds theme before copying it to tmp folder
def npm_build(f):
print("Building theme " + f)
os.system("cd " + f + " && npm i && npm run build")
# Delete theme.zip
if os.path.exists("theme.zip"):
os.remove("theme.zip")
# Delete tmp folder
if os.path.exists("tmp"):
shutil.rmtree("tmp")
# Copy theme bundle to jar structure
if os.path.exists("resources"):
shutil.rmtree("resources")
# Go through every folder and copy public folder to tmp folder with name of folder
for folder in os.listdir("."):
if os.path.isdir(folder):
# Check if theme has package.json
if os.path.exists(folder + "/package.json"):
# Build theme
npm_build(folder)
# Check if theme has public folder to copy
if os.path.exists(folder + "/public"):
# Copy theme to tmp folder
shutil.copytree(folder + "/public", "tmp/" + folder)
else:
print("Folder " + folder + " has no public folder")
# Zip into theme bundle
shutil.make_archive("theme", "zip", "tmp")
# Delete tmp folder
if os.path.exists("tmp"):
shutil.rmtree("tmp")
# Copy theme bundle to jar structure
if os.path.exists("resources"):
shutil.rmtree("resources")
# Create folder structure
os.makedirs("resources/assets/liquidbounce")
shutil.copy("theme.zip", "resources/assets/liquidbounce/default_theme.zip")