12
12
import hashlib
13
13
import os
14
14
import platform
15
+ import shutil
15
16
from pathlib import Path
16
17
from string import Template
17
18
from typing import List , Tuple , Union
18
19
20
+ _ARCHIVE_FORMAT = 'zip'
19
21
_HASH_FILE_EXT = '.sha256'
20
22
_OS_TO_CLI_DIST_TEMPLATE = {
21
23
'darwin' : Template ('cycode-mac$suffix$ext' ),
@@ -125,6 +127,14 @@ def get_cli_hash_path(output_path: Path, is_onedir: bool) -> str:
125
127
return os .path .join (output_path , get_cli_hash_filename (is_onedir ))
126
128
127
129
130
+ def get_cli_archive_filename (is_onedir : bool ) -> str :
131
+ return get_cli_file_name (suffix = get_cli_file_suffix (is_onedir ))
132
+
133
+
134
+ def get_cli_archive_path (output_path : Path , is_onedir : bool ) -> str :
135
+ return os .path .join (output_path , get_cli_archive_filename (is_onedir ))
136
+
137
+
128
138
def process_executable_file (input_path : Path , is_onedir : bool ) -> str :
129
139
output_path = input_path .parent
130
140
hash_file_path = get_cli_hash_path (output_path , is_onedir )
@@ -133,6 +143,10 @@ def process_executable_file(input_path: Path, is_onedir: bool) -> str:
133
143
hashes = get_hashes_of_every_file_in_the_directory (input_path )
134
144
normalized_hashes = normalize_hashes_db (hashes , input_path )
135
145
write_hashes_db_to_file (normalized_hashes , hash_file_path )
146
+
147
+ archived_file_path = get_cli_archive_path (output_path , is_onedir )
148
+ shutil .make_archive (archived_file_path , _ARCHIVE_FORMAT , input_path )
149
+ shutil .rmtree (input_path )
136
150
else :
137
151
file_hash = get_hash_of_file (input_path )
138
152
write_hash_to_file (file_hash , hash_file_path )
0 commit comments