@@ -6,7 +6,7 @@ use std::{ fs, error::Error, path::PathBuf, env };
66
77use validators:: { env:: EnvValidator , Recommend :: RecommendValidator } ;
88
9- use crate :: validators:: { message:: { Message , self } , package:: { PackageValidator } , config:: ConfigValidator , common:: { Validator } } ;
9+ use crate :: validators:: { message:: { Message , MessageKind } , package:: { PackageValidator } , config:: ConfigValidator , common:: { Validator } } ;
1010
1111#[ macro_use]
1212extern crate napi_derive;
@@ -15,38 +15,38 @@ extern crate napi_derive;
1515pub fn validate_config ( config_str : String ) {
1616 let result = validate_config_core ( config_str) ;
1717 if let Err ( e) = result {
18- println ! ( "{}" , Message { kind: message :: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
18+ println ! ( "{}" , Message { kind: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
1919 }
2020}
2121
2222#[ napi]
2323pub fn validate_package ( app_path : String , node_modules_path : String , cli_version : String ) {
2424 let result = validate_package_core ( app_path, node_modules_path, cli_version) ;
2525 if let Err ( e) = result {
26- println ! ( "{}" , Message { kind: message :: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
26+ println ! ( "{}" , Message { kind: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
2727 }
2828}
2929
3030#[ napi]
3131pub fn validate_env ( ) {
3232 let result = validate_env_core ( ) ;
3333 if let Err ( e) = result {
34- println ! ( "{}" , Message { kind: message :: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
34+ println ! ( "{}" , Message { kind: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
3535 }
3636}
3737
3838#[ napi]
39- pub fn validate_recommend ( app_path : String , node_modules_path : String ) {
40- let result = validate_recommend_core ( app_path, node_modules_path ) ;
39+ pub fn validate_recommend ( app_path : String ) {
40+ let result = validate_recommend_core ( app_path) ;
4141 if let Err ( e) = result {
42- println ! ( "{}" , Message { kind: message :: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
42+ println ! ( "{}" , Message { kind: MessageKind :: Error , content: e. to_string( ) , solution: None } ) ;
4343 }
4444}
4545
4646fn validate_config_core ( config_str : String ) -> Result < ( ) , Box < dyn Error > > {
4747 let tip = Message {
48- kind : validators :: message :: MessageKind :: Info ,
49- content : String :: from ( "开始进行项目配置验证 !" ) ,
48+ kind : MessageKind :: Info ,
49+ content : String :: from ( "验证项目配置配置 !" ) ,
5050 solution : None
5151 } ;
5252 println ! ( "{}" , tip) ;
@@ -63,7 +63,7 @@ fn validate_config_core(config_str: String) -> Result<(), Box<dyn Error>> {
6363 Ok ( config_validator) => config_validator. validate ( ) ,
6464 Err ( e) => vec ! [
6565 Message {
66- kind: validators :: message :: MessageKind :: Error ,
66+ kind: MessageKind :: Error ,
6767 content: e. to_string( ) ,
6868 solution: None
6969 }
@@ -74,15 +74,15 @@ fn validate_config_core(config_str: String) -> Result<(), Box<dyn Error>> {
7474 println ! ( "{}" , message) ;
7575 }
7676 } else {
77- println ! ( "{}" , Message { kind: message :: MessageKind :: Success , content: "项目配置正确!" . to_string( ) , solution: None } ) ;
77+ println ! ( "{}" , Message { kind: MessageKind :: Success , content: "项目配置正确!" . to_string( ) , solution: None } ) ;
7878 }
7979 Ok ( ( ) )
8080}
8181
8282fn validate_package_core ( app_path : String , node_modules_path : String , cli_version : String ) -> Result < ( ) , Box < dyn Error > > {
8383 let tip = Message {
84- kind : validators :: message :: MessageKind :: Info ,
85- content : String :: from ( "开始进行项目依赖安装正确性验证 !" ) ,
84+ kind : MessageKind :: Info ,
85+ content : String :: from ( "验证项目依赖安装正确性 !" ) ,
8686 solution : None
8787 } ;
8888 println ! ( "{}" , tip) ;
@@ -95,7 +95,7 @@ fn validate_package_core(app_path: String, node_modules_path: String, cli_versio
9595 Ok ( package_validator) => package_validator. validate ( ) ,
9696 Err ( e) => vec ! [
9797 Message {
98- kind: validators :: message :: MessageKind :: Error ,
98+ kind: MessageKind :: Error ,
9999 content: e. to_string( ) ,
100100 solution: None
101101 }
@@ -108,6 +108,12 @@ fn validate_package_core(app_path: String, node_modules_path: String, cli_versio
108108}
109109
110110fn validate_env_core ( ) -> Result < ( ) , Box < dyn Error > > {
111+ let tip = Message {
112+ kind : MessageKind :: Info ,
113+ content : String :: from ( "验证环境信息!" ) ,
114+ solution : None
115+ } ;
116+ println ! ( "{}" , tip) ;
111117 let env_validator = EnvValidator :: build ( ) ;
112118 let messages = env_validator. validate ( ) ;
113119 for message in messages {
@@ -116,13 +122,19 @@ fn validate_env_core() -> Result<(), Box<dyn Error>> {
116122 Ok ( ( ) )
117123}
118124
119- fn validate_recommend_core ( app_path : String , node_modules_path : String ) -> Result < ( ) , Box < dyn Error > > {
120- let recommend_validator_result = RecommendValidator :: build ( & app_path, & node_modules_path) ;
125+ fn validate_recommend_core ( app_path : String ) -> Result < ( ) , Box < dyn Error > > {
126+ let tip = Message {
127+ kind : MessageKind :: Info ,
128+ content : String :: from ( "验证最佳实践!" ) ,
129+ solution : None
130+ } ;
131+ println ! ( "{}" , tip) ;
132+ let recommend_validator_result = RecommendValidator :: build ( & app_path) ;
121133 let messages = match recommend_validator_result {
122134 Ok ( recommend_validator) => recommend_validator. validate ( ) ,
123135 Err ( e) => vec ! [
124136 Message {
125- kind: validators :: message :: MessageKind :: Error ,
137+ kind: MessageKind :: Error ,
126138 content: e. to_string( ) ,
127139 solution: None
128140 }
0 commit comments