Skip to content

Commit bb10283

Browse files
authored
Clean up infrastructure (#375)
Also fixes the build-frontend script.
1 parent 4a20a5b commit bb10283

File tree

9 files changed

+88
-168
lines changed

9 files changed

+88
-168
lines changed

.github/workflows/remove-old-artifacts.yml

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

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "recommendations": ["Vue.volar", "esbenp.prettier-vscode"] }

.vscode/settings.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"githubPullRequests.ignoredPullRequestBranches": [
3-
"main"
4-
]
5-
}
2+
"[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
3+
"[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }
4+
}

scripts/build-backend

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,22 @@
11
#!/usr/bin/env python3
22

33
import argparse
4+
import shlex
45
import subprocess
6+
from pathlib import Path
57

6-
def build():
7-
subprocess.run(
8-
["mvn", "package", "site", "jacoco:report-aggregate"],
9-
cwd="backend",
10-
check=True,
11-
)
8+
DIR: Path = Path("backend")
129

13-
def clean():
14-
subprocess.run(
15-
["mvn", "clean"],
16-
cwd="backend",
17-
check=True,
18-
)
1910

20-
def main():
21-
parser = argparse.ArgumentParser()
22-
parser.add_argument(
23-
"--clean", "-c",
24-
action="store_true",
25-
help="clean up build files instead of building"
26-
)
27-
args = parser.parse_args()
11+
def run(*cmd: str | Path) -> None:
12+
print(f"$ {shlex.join(str(arg) for arg in cmd)}")
13+
subprocess.run(cmd, check=True, cwd=DIR)
2814

29-
if args.clean:
30-
clean()
31-
else:
32-
try:
33-
build()
34-
except subprocess.CalledProcessError:
35-
print()
36-
print("Build failed :(")
37-
exit(1)
38-
else:
39-
print()
40-
print("Build successful :)")
41-
print("The backend.jar is at backend/backend/target/backend.jar")
42-
print("The runner.jar is at backend/runner/target/runner.jar")
4315

44-
if __name__ == "__main__":
45-
main()
16+
parser = argparse.ArgumentParser()
17+
_args = parser.parse_args()
18+
19+
run("mvn", "package")
20+
print()
21+
print("The backend.jar is at backend/backend/target/backend.jar")
22+
print("The runner.jar is at backend/runner/target/runner.jar")

scripts/build-frontend

Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,36 @@
11
#!/usr/bin/env python3
22

33
import argparse
4-
import shutil
4+
import shlex
55
import subprocess
6+
from pathlib import Path
67

7-
def build(env):
8-
subprocess.run(
9-
["yarnpkg", "install"],
10-
cwd="frontend",
11-
check=True,
12-
)
8+
DIR: Path = Path("frontend")
139

14-
if env is None:
15-
subprocess.run(
16-
["yarnpkg", "build"],
17-
cwd="frontend",
18-
check=True,
19-
)
20-
else:
21-
subprocess.run(
22-
["yarnpkg", "build", "--mode", env],
23-
cwd="frontend",
24-
check=True,
25-
)
2610

27-
def clean(clean_all=False):
28-
print("Removing frontend/dist/")
29-
shutil.rmtree("frontend/dist/", ignore_errors=True)
11+
def run(*cmd: str | Path) -> None:
12+
print(f"$ {shlex.join(str(arg) for arg in cmd)}")
13+
subprocess.run(cmd, check=True, cwd=DIR)
3014

31-
if clean_all:
32-
print("Removing frontend/node_modules/")
33-
shutil.rmtree("frontend/node_modules/", ignore_errors=True)
3415

35-
def main():
36-
parser = argparse.ArgumentParser()
37-
parser.add_argument(
38-
"--env",
39-
metavar="NAME",
40-
help="name of the build environment to use. A corresponding file"
41-
" '.env.NAME' must be present in the frontend/ directory"
42-
)
43-
parser.add_argument(
44-
"--clean", "-c",
45-
action="store_true",
46-
help="clean up build files instead of building"
47-
)
48-
parser.add_argument(
49-
"--clean-all",
50-
action="store_true",
51-
help="like --clean, but also removes node_modules"
52-
)
53-
args = parser.parse_args()
16+
parser = argparse.ArgumentParser()
17+
parser.add_argument(
18+
"--env",
19+
metavar="NAME",
20+
help="name of the build environment to use. A corresponding file"
21+
" '.env.NAME' must be present in the frontend/ directory",
22+
)
23+
args = parser.parse_args()
5424

55-
if args.clean or args.clean_all:
56-
clean(args.clean_all)
57-
else:
58-
try:
59-
build(args.env)
60-
except subprocess.CalledProcessError:
61-
print()
62-
print("Build failed :(")
63-
exit(1)
64-
else:
65-
print()
66-
print("Build successful :)")
67-
print("The frontend files are at frontend/dist/")
25+
run(
26+
"yarnpkg",
27+
"install",
28+
# Yarnpkg complains about incompatible node versions, but the build seems to
29+
# run fine, so we just tell it to shut up.
30+
"--ignore-engines",
31+
)
6832

69-
if __name__ == "__main__":
70-
main()
33+
if args.env is None:
34+
run("yarnpkg", "build")
35+
else:
36+
run("yarnpkg", "build", "--mode", args.env)

scripts/clean-backend

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import shlex
5+
import subprocess
6+
from pathlib import Path
7+
8+
DIR: Path = Path("backend")
9+
10+
11+
def run(*cmd: str | Path) -> None:
12+
print(f"$ {shlex.join(str(arg) for arg in cmd)}")
13+
subprocess.run(cmd, check=True, cwd=DIR)
14+
15+
16+
parser = argparse.ArgumentParser()
17+
_args = parser.parse_args()
18+
19+
run("mvn", "clean")

scripts/clean-frontend

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import shutil
5+
from pathlib import Path
6+
7+
DIR: Path = Path("frontend")
8+
9+
10+
def rm(path: Path) -> None:
11+
print(f"Removing {path}")
12+
shutil.rmtree(path, ignore_errors=True)
13+
14+
15+
parser = argparse.ArgumentParser()
16+
parser.add_argument(
17+
"--all",
18+
"-a",
19+
action="store_true",
20+
help="remove node_modules as well",
21+
)
22+
args = parser.parse_args()
23+
24+
rm(DIR / "dist")
25+
26+
if args.all:
27+
rm(DIR / "node_modules")

scripts/deploy-kit/deploy.sh

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

scripts/deploy-kit/kit-deployment.crt.pem

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

0 commit comments

Comments
 (0)