-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.py
39 lines (31 loc) · 1.3 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
import json
import logging
import os
import shutil
import zipfile
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('build')
project_root_dir = os.path.dirname(__file__)
data_dir = os.path.join(project_root_dir, 'data')
releases_dir = os.path.join(project_root_dir, 'build', 'releases')
def main():
if os.path.exists(releases_dir):
shutil.rmtree(releases_dir)
os.makedirs(releases_dir)
package_json_file_path = os.path.join(data_dir, 'package.json')
with open(package_json_file_path, 'r', encoding='utf-8') as file:
package_info: dict = json.loads(file.read())
package_name: str = package_info['name']
package_version: str = package_info['version']
extension_file_path = os.path.join(releases_dir, f'{package_name}-v{package_version}.aseprite-extension')
with zipfile.ZipFile(extension_file_path, 'w') as file:
for file_dir, _, file_names in os.walk(data_dir):
for file_name in file_names:
if file_name.startswith('.'):
continue
file_path = os.path.join(file_dir, file_name)
arc_path = file_path.removeprefix(f'{data_dir}/')
file.write(file_path, arc_path)
logger.info("Pack file: '%s'", arc_path)
if __name__ == '__main__':
main()