File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import re
2+ import typer
3+ import logging
4+ from ...projects import ProjectData
5+
6+ __all__ = ()
7+
8+ logger = logging .getLogger (__name__ )
9+
10+ def check_project_data_validity (project_data : ProjectData ) -> None :
11+ project_name = project_data .name
12+
13+ is_project_name_allowed = bool (
14+ re .fullmatch (r'^[a-zA-Z]+$' , project_name )
15+ )
16+
17+ if not is_project_name_allowed :
18+ logger .error (
19+ "Project name can only contain letters. Symbols, " \
20+ "numbers, spaces, dashes and etc are not allowed!"
21+ )
22+
23+ raise typer .Exit (1 )
24+
25+ if any (char .isupper () for char in project_name ):
26+ logger .error (
27+ "Project name must be all lowercase!"
28+ )
29+
30+ raise typer .Exit (1 )
31+
32+ return None
Original file line number Diff line number Diff line change 99from pathlib import Path
1010from typer import Option , Typer , Exit
1111
12+ from .checks import check_project_data_validity
1213from .binary import format_and_copy_binary_to_dist
1314from .nsis import format_config_and_make_nsis_installer
1415from .icons import get_platform_icon_path , format_icon_with_project_name
@@ -89,12 +90,12 @@ def package(
8990 raise Exit (1 )
9091
9192 if project == ProjectType .CARGO :
92- projects_data : Optional [ConfigProjectData ] = config_data .get ("project" , None )
93+ projects_config_data : Optional [ConfigProjectData ] = config_data .get ("project" , None )
9394
9495 cargo_crate_name : Optional [str ] = None
9596
96- if projects_data is not None :
97- cargo_config_data = projects_data .get ("cargo" , None )
97+ if projects_config_data is not None :
98+ cargo_config_data = projects_config_data .get ("cargo" , None )
9899
99100 if cargo_config_data is not None :
100101 cargo_crate_name = cargo_config_data .get ("bin-crate" , None )
@@ -109,6 +110,8 @@ def package(
109110 if project_data is None :
110111 raise Exit (1 )
111112
113+ check_project_data_validity (project_data )
114+
112115 toolchain_name = get_cargo_toolchain (platform_format )
113116
114117 if toolchain_name is None :
You can’t perform that action at this time.
0 commit comments