From bce99aecb4160291a026dcd4750055f9079099f8 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Thu, 18 Jul 2024 15:26:18 +0300 Subject: [PATCH] fix(nsis): nondestructive removal of install directory (#260) --- .changes/nsis-graceful-remove.md | 7 ++++++ bindings/packager/nodejs/src-ts/config.d.ts | 24 ++++++++++++++----- .../packager/src/package/nsis/installer.nsi | 12 ++++------ 3 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 .changes/nsis-graceful-remove.md diff --git a/.changes/nsis-graceful-remove.md b/.changes/nsis-graceful-remove.md new file mode 100644 index 00000000..b750727d --- /dev/null +++ b/.changes/nsis-graceful-remove.md @@ -0,0 +1,7 @@ +--- +"cargo-packager": "patch" +"@crabnebula/packager": "patch" +--- + +Fix NSIS uninstaller removing the uninstall directory even if it was not empty. + diff --git a/bindings/packager/nodejs/src-ts/config.d.ts b/bindings/packager/nodejs/src-ts/config.d.ts index 9cfa89f1..ee1dd4fb 100644 --- a/bindings/packager/nodejs/src-ts/config.d.ts +++ b/bindings/packager/nodejs/src-ts/config.d.ts @@ -95,6 +95,10 @@ export type Resource = target: string; [k: string]: unknown; }; +/** + * A list of dependencies specified as either a list of Strings or as a path to a file that lists the dependencies, one per line. + */ +export type Dependencies = string[] | string; /** * A wix language. */ @@ -409,6 +413,8 @@ export interface MacOsConfig { exceptionDomain?: string | null; /** * Code signing identity. + * + * This is typically of the form: `"Developer ID Application: TEAM_NAME (TEAM_ID)"`. */ signingIdentity?: string | null; /** @@ -425,19 +431,25 @@ export interface MacOsConfig { infoPlistPath?: string | null; } /** - * The Linux debian configuration. + * The Linux Debian configuration. */ export interface DebianConfig { /** - * The list of debian dependencies. + * The list of Debian dependencies. */ - depends?: string[] | null; + depends?: Dependencies | null; /** * Path to a custom desktop file Handlebars template. * * Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`. * - * Default file contents: ```text [Desktop Entry] Categories={{categories}} {{#if comment}} Comment={{comment}} {{/if}} Exec={{exec}} Icon={{icon}} Name={{name}} Terminal=false Type=Application {{#if mime_type}} MimeType={{mime_type}} {{/if}} ``` + * Default file contents: ```text [Desktop Entry] Categories={{categories}} {{#if comment}} Comment={{comment}} {{/if}} Exec={{exec}} {{exec_arg}} Icon={{icon}} Name={{name}} Terminal=false Type=Application {{#if mime_type}} MimeType={{mime_type}} {{/if}} ``` + * + * The `{{exec_arg}}` will be set to: * "%F", if at least one [Config::file_associations] was specified but no deep link protocols were given. * The "%F" arg means that your application can be invoked with multiple file paths. * "%U", if at least one [Config::deep_link_protocols] was specified. * The "%U" arg means that your application can be invoked with multiple URLs. * If both [Config::file_associations] and [Config::deep_link_protocols] were specified, the "%U" arg will be used, causing the file paths to be passed to your app as `file://` URLs. * An empty string "" (nothing) if neither are given. * This means that your application will never be invoked with any URLs or file paths. + * + * To specify a custom `exec_arg`, just use plaintext directly instead of `{{exec_arg}}`: ```text Exec={{exec}} %u ``` + * + * See more here: . */ desktopTemplate?: string | null; /** @@ -497,9 +509,9 @@ export interface PacmanConfig { /** * List of softwares that must be installed for the app to build and run. * - * See : + * See : */ - depends?: string[] | null; + depends?: Dependencies | null; /** * Additional packages that are provided by this app. * diff --git a/crates/packager/src/package/nsis/installer.nsi b/crates/packager/src/package/nsis/installer.nsi index 071479f8..e49add81 100644 --- a/crates/packager/src/package/nsis/installer.nsi +++ b/crates/packager/src/package/nsis/installer.nsi @@ -610,14 +610,10 @@ Section Uninstall ; Delete uninstaller Delete "$INSTDIR\uninstall.exe" - ${If} $DeleteAppDataCheckboxState == 1 - RMDir /R /REBOOTOK "$INSTDIR" - ${Else} - {{#each resources_dirs}} - RMDir /REBOOTOK "$INSTDIR\\{{this}}" - {{/each}} - RMDir "$INSTDIR" - ${EndIf} + {{#each resources_dirs}} + RMDir /REBOOTOK "$INSTDIR\\{{this}}" + {{/each}} + RMDir "$INSTDIR" ; Remove start menu shortcut !insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder