-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
49 lines (43 loc) · 1.83 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
from pathlib import Path
from os.path import join
from shutil import copy, rmtree
from subprocess import run
from time import sleep
EXCLUSIONS = [
'database.sqlite',
'favicons/README.md',
'files/',
'logs/',
'main.log',
'resources/key.bin',
'web/',
]
def main():
rmtree('build', ignore_errors=True)
Path('build').mkdir(parents=True, exist_ok=True)
for file_path in Path('src').rglob('*'):
if file_path.is_dir():
for exclusion in EXCLUSIONS:
if str(file_path).startswith(join('src', exclusion)):
break
else:
Path('build').joinpath(file_path.relative_to('src')).mkdir(parents=True, exist_ok=True)
if file_path.is_file():
for exclusion in EXCLUSIONS:
if str(file_path).startswith(join('src', exclusion)):
break
else:
Path('build').joinpath(file_path.relative_to('src')).parent.mkdir(parents=True, exist_ok=True)
copy(file_path, Path('build').joinpath(file_path.relative_to('src')))
rmtree('src/web/dist', ignore_errors=True)
run(['ng', 'build', '--configuration', 'production'], cwd=Path('src/web/src').absolute(), check=True, stdout=None)
sleep(1)
Path('build/web').mkdir(parents=True, exist_ok=True)
for file_path in Path('src/web/dist/web/browser').rglob('*'):
if file_path.is_dir():
Path('build/web').joinpath(file_path.relative_to('src/web/dist/web/browser')).mkdir(parents=True, exist_ok=True)
if file_path.is_file():
Path('build/web').joinpath(file_path.relative_to('src/web/dist/web/browser')).parent.mkdir(parents=True, exist_ok=True)
copy(file_path, Path('build/web').joinpath(file_path.relative_to('src/web/dist/web/browser')))
if __name__ == '__main__':
main()