44 from ...config .data import ConfigProjectData
55
66import os
7+ import shutil
78import logging
89from pathlib import Path
910from typer import Option , Typer , Exit
1011
1112from .binary import format_and_copy_binary_to_dist
1213from .nsis import format_config_and_make_nsis_installer
14+ from .icons import get_platform_icon_path , format_icon_with_project_name
1315
1416from ...config import get_config_data
1517from ...project_type import ProjectType
@@ -29,14 +31,14 @@ def package(
2931 Option (
3032 help = "The packaging format or platform we are targeting. Choose a less generic option if you only want to " \
3133 "package towards ONE specific format such as 'windows-setup', otherwise all available formats " \
32- "of such platform will be automatically packaged."
34+ "of such platform will be automatically packaged (as is the case with 'windows') ."
3335 )
3436 ],
3537 bin_output_name : Annotated [
3638 Optional [str ],
3739 Option (
3840 help = "Override the default binary name prefixed in front of the binary suffix " \
39- "(e.g: 'bin-name-linux-x86_64', 'bib -name-win-x86_64-setup.exe', 'bin-name-macos-x86_64')."
41+ "(e.g: 'bin-name-linux-x86_64', 'bin -name-win-x86_64-setup.exe', 'bin-name-macos-x86_64')."
4042 )
4143 ] = None ,
4244):
@@ -54,6 +56,31 @@ def package(
5456 raise Exit (1 )
5557
5658 display_name : Optional [str ] = config_data .get ("display-name" , None )
59+ icons_config_path : Optional [str ] = config_data .get ("icons" , None )
60+
61+ if icons_config_path is None :
62+ logger .error (
63+ "Icons folder is required to be specific in the config and at " \
64+ "least an original icon must be present (e.g: 'original.png')!" \
65+ '\n icons = "./assets/icons"'
66+ )
67+ raise Exit (1 )
68+
69+ icons_path = Path (icons_config_path )
70+
71+ if not icons_path .exists ():
72+ logger .error (f"Icons folder path does not exist ('{ icons_path } ')!" )
73+
74+ raise Exit (1 )
75+
76+ platform_icon_path = get_platform_icon_path (icons_path , platform_format )
77+
78+ if platform_icon_path is None :
79+ logger .error (
80+ "At least an original icon is required in your icons " \
81+ f"path at '{ icons_config_path } ' (e.g: 'original.png')!"
82+ )
83+ raise Exit (1 )
5784
5885 if project == ProjectType .CARGO :
5986 projects_data : Optional [ConfigProjectData ] = config_data .get ("project" , None )
@@ -115,14 +142,24 @@ def package(
115142 if platform_format & PlatformFormat .WINDOWS_SETUP :
116143 binary_path = cargo_release_path .joinpath (f"{ project_data .name } .exe" )
117144
145+ platform_icon_path = format_icon_with_project_name (
146+ platform_icon_path ,
147+ temp_folder_path ,
148+ project_name = project_data .name
149+ )
150+
118151 format_config_and_make_nsis_installer (
119152 binary_path ,
120153 binary_name = binary_name ,
121154 binary_suffix = "win-x86_64-setup.exe" ,
122155 dist_folder_path = dist_folder_path ,
123156 temp_folder_path = temp_folder_path ,
124- display_name = display_name if display_name is not None else project_data .name ,
157+ display_name = display_name ,
158+ icon_path = platform_icon_path ,
125159 project_data = project_data
126160 )
127161
128- logger .info ("WIP!" )
162+ logger .debug ("Removing temp dir..." )
163+ shutil .rmtree (temp_folder_path , ignore_errors = True )
164+
165+ logger .info ("This command is WIP!" )
0 commit comments