Skip to content

Commit 2b7a64c

Browse files
committed
feat: add support for display name for nsis and fix uninstaller not removing shortcut.
closes #5, closes #12
1 parent 70b8e31 commit 2b7a64c

8 files changed

Lines changed: 63 additions & 55 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ suap = "suap.main:app"
1414

1515
[dependency-groups]
1616
dev = [
17-
"ty>=0.0.17",
18-
"ruff>=0.15.1"
17+
"ty>=0.0.21",
18+
"ruff>=0.15.5"
1919
]
2020

2121
[build-system]
2222
requires = ["setuptools >= 77.0.3"]
2323
build-backend = "setuptools.build_meta"
2424

2525
[tool.setuptools.dynamic]
26-
version = { attr = "suap.version.__version__" }
26+
version = { attr = "suap.__version__" }
2727

2828
[tool.setuptools.package-data]
29-
suap = ["templates/*"]
29+
suap = ["templates/*"]

suap/commands/packaging/nsis.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def format_config_and_make_nsis_installer(
2121
binary_suffix: str,
2222
dist_folder_path: Path,
2323
temp_folder_path: Path,
24+
display_name: str,
2425
project_data: ProjectData,
2526
):
2627
logger.debug(
@@ -52,6 +53,7 @@ def format_config_and_make_nsis_installer(
5253
"suap-binary-name": binary_name,
5354
"suap-binary-path": f"../{binary_path}",
5455
"suap-binary-dist-path": str(binary_dist_path),
56+
"suap-display-name": display_name,
5557

5658
"suap-project-name": project_data.name,
5759
"suap-project-version": f"{semver.major}.{semver.minor}.{semver.patch}" \

suap/commands/packaging/package.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def package(
5353
if config_data is None:
5454
raise Exit(1)
5555

56+
display_name: Optional[str] = config_data.get("display-name", None)
57+
5658
if project == ProjectType.CARGO:
5759
projects_data: Optional[ConfigProjectData] = config_data.get("project", None)
5860

@@ -119,6 +121,7 @@ def package(
119121
binary_suffix = "win-x86_64-setup.exe",
120122
dist_folder_path = dist_folder_path,
121123
temp_folder_path = temp_folder_path,
124+
display_name = display_name if display_name is not None else project_data.name,
122125
project_data = project_data
123126
)
124127

suap/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ def get_config_data(project_root_dir: Path) -> Optional[ConfigData]:
2828

2929
with open(config_path, mode = "rb") as file:
3030
logger.debug("Parsing toml config...")
31-
config_data = tomllib.load(file) # ty: ignore[invalid-assignment]
31+
config_data = tomllib.load(file)
3232

3333
return config_data

suap/config/data.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
class ConfigProjectData(TypedDict):
1515
cargo: ConfigCargoProjectData
1616

17-
class ConfigData(TypedDict):
18-
version: int
19-
project: ConfigProjectData
17+
ConfigData = TypedDict(
18+
"ConfigData",
19+
{
20+
"version": int,
21+
"display-name": str,
22+
"project": ConfigProjectData
23+
}
24+
)

suap/templates/nsis_installer_script.nsi

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
!include "MUI2.nsh"
22

3-
# TODO: All "suap-project-name" keys except "InstallDir" and
4-
# "CreateShortcut" need to be changed to "suap-display-name"
5-
# when that is available.
6-
7-
Name "{suap-project-name}"
3+
Name "{suap-display-name}"
84
OutFile "{suap-binary-dist-path}"
95
InstallDir "$PROGRAMFILES64\cloudy-org\{suap-project-name}"
106

117
VIProductVersion "{suap-project-version}"
12-
VIAddVersionKey "ProductName" "{suap-project-name}"
8+
VIAddVersionKey "ProductName" "{suap-display-name}"
139
VIAddVersionKey "FileDescription" "{suap-project-description}"
1410
VIAddVersionKey "FileVersion" "{suap-project-version}"
1511

@@ -33,7 +29,7 @@ Section "MainSection"
3329
WriteUninstaller "$INSTDIR\uninstall.exe"
3430

3531
# Windows needs to know our application can be uninstalled via it's uninstall apps settings.
36-
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\{suap-project-name}" "DisplayName" "{suap-project-name}"
32+
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\{suap-project-name}" "DisplayName" "{suap-display-name}"
3733
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\{suap-project-name}" "UninstallString" "$INSTDIR\uninstall.exe"
3834

3935
CreateShortcut "$DESKTOP\{suap-project-name}.lnk" "$INSTDIR\{suap-binary-name}.exe"
@@ -45,5 +41,7 @@ Section "Uninstall"
4541
Delete "$INSTDIR\uninstall.exe"
4642
RMDir "$INSTDIR"
4743

44+
Delete "$DESKTOP\{suap-project-name}.lnk"
45+
4846
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\{suap-project-name}"
4947
SectionEnd

ty.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[rules]
2-
missing-typed-dict-key = "ignore"
2+
# missing-typed-dict-key = "ignore"

uv.lock

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)