4
4
import click
5
5
6
6
from cycode .cli .models import Document
7
- from cycode .cli .utils .path_utils import get_file_dir , join_paths
7
+ from cycode .cli .utils .path_utils import get_file_content , get_file_dir , join_paths
8
8
from cycode .cli .utils .shell_executor import shell
9
9
from cycode .cyclient import logger
10
10
@@ -39,6 +39,23 @@ def get_manifest_file_path(self, document: Document) -> str:
39
39
else document .path
40
40
)
41
41
42
+ def try_restore_dependencies (self , document : Document ) -> Optional [Document ]:
43
+ manifest_file_path = self .get_manifest_file_path (document )
44
+ restore_file_path = build_dep_tree_path (document .path , self .get_lock_file_name ())
45
+
46
+ if self .verify_restore_file_already_exist (restore_file_path ):
47
+ restore_file_content = get_file_content (restore_file_path )
48
+ else :
49
+ restore_file_content = execute_command (
50
+ self .get_command (manifest_file_path ), manifest_file_path , self .command_timeout
51
+ )
52
+
53
+ return Document (restore_file_path , restore_file_content , self .is_git_diff )
54
+
55
+ @abstractmethod
56
+ def verify_restore_file_already_exist (self , restore_file_path : str ) -> bool :
57
+ pass
58
+
42
59
@abstractmethod
43
60
def is_project (self , document : Document ) -> bool :
44
61
pass
@@ -50,11 +67,3 @@ def get_command(self, manifest_file_path: str) -> List[str]:
50
67
@abstractmethod
51
68
def get_lock_file_name (self ) -> str :
52
69
pass
53
-
54
- def try_restore_dependencies (self , document : Document ) -> Optional [Document ]:
55
- manifest_file_path = self .get_manifest_file_path (document )
56
- return Document (
57
- build_dep_tree_path (document .path , self .get_lock_file_name ()),
58
- execute_command (self .get_command (manifest_file_path ), manifest_file_path , self .command_timeout ),
59
- self .is_git_diff ,
60
- )
0 commit comments