|
|
@@ -23,6 +23,8 @@ export interface INsisComposerOptions {
|
|
|
|
|
|
languages: string[];
|
|
|
|
|
|
+ installDirectory: string;
|
|
|
+
|
|
|
// Output.
|
|
|
output: string;
|
|
|
|
|
|
@@ -66,31 +68,54 @@ export class NsisComposer {
|
|
|
|
|
|
public async make(): Promise<string> {
|
|
|
|
|
|
- return `
|
|
|
-${ NsisComposer.DIVIDER }
|
|
|
+ return `${ NsisComposer.DIVIDER }
|
|
|
#
|
|
|
# Generated by nsis-gen.
|
|
|
#
|
|
|
${ NsisComposer.DIVIDER }
|
|
|
|
|
|
-${ await this.makeGeneralSection() }
|
|
|
+${ await this.makeStrings() }
|
|
|
|
|
|
-${ await this.makeStringsSection() }
|
|
|
+${ await this.makeGeneral() }
|
|
|
|
|
|
-${ await this.makeModernUISection() }
|
|
|
+${ await this.makeModernUI() }
|
|
|
|
|
|
-${ await this.makeVersionSection() }
|
|
|
+${ await this.makeVersioning() }
|
|
|
|
|
|
-${ await this.makeHookSection() }
|
|
|
+${ await this.makeHooks() }
|
|
|
|
|
|
${ await this.makeInstallSection() }
|
|
|
|
|
|
-${ await this.makeUninstallSection() }
|
|
|
-`;
|
|
|
+${ await this.makeUninstallSection() }`;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ protected async makeStrings(): Promise<string> {
|
|
|
+ return `${ NsisComposer.DIVIDER }
|
|
|
+#
|
|
|
+# Strings
|
|
|
+#
|
|
|
+${ NsisComposer.DIVIDER }
|
|
|
+
|
|
|
+!define _APPNAME "${ this.options.appName }"
|
|
|
+!define _COMPANYNAME "${ this.options.companyName }"
|
|
|
+!define _DESCRIPTION "${ this.options.description }"
|
|
|
+!define _VERSION "${ this.fixedVersion }"
|
|
|
+!define _COPYRIGHT "${ this.options.copyright }"
|
|
|
+!define _OUTPUT "${ win32.normalize(resolve(this.options.output)) }"
|
|
|
+
|
|
|
+# FIXME: More translations.
|
|
|
+
|
|
|
+LangString CREATE_DESKTOP_SHORTCUT 1033 "Create Desktop Shortcut"
|
|
|
+LangString CREATE_DESKTOP_SHORTCUT 2052 "创建桌面快捷方式"
|
|
|
+LangString CREATE_DESKTOP_SHORTCUT 1028 "建立桌面捷徑"
|
|
|
|
|
|
+LangString INSTALLING 1033 "Installing"
|
|
|
+LangString INSTALLING 2052 "正在安装"
|
|
|
+LangString INSTALLING 1028 "安裝中"`;
|
|
|
}
|
|
|
|
|
|
- protected async makeGeneralSection(): Promise<string> {
|
|
|
+ protected async makeGeneral(): Promise<string> {
|
|
|
return `${ NsisComposer.DIVIDER }
|
|
|
#
|
|
|
# General
|
|
|
@@ -99,9 +124,9 @@ ${ NsisComposer.DIVIDER }
|
|
|
|
|
|
Unicode true
|
|
|
|
|
|
-Name "${ this.options.appName }"
|
|
|
-Caption "${ this.options.appName }"
|
|
|
-BrandingText "${ this.options.appName } ${ this.fixedVersion }"
|
|
|
+Name "\${_APPNAME}"
|
|
|
+Caption "\${_APPNAME}"
|
|
|
+BrandingText "\${_APPNAME} \${_VERSION}"
|
|
|
${
|
|
|
this.options.icon
|
|
|
? `Icon "${ win32.normalize(resolve(this.options.icon)) }"`
|
|
|
@@ -114,35 +139,16 @@ ${
|
|
|
}
|
|
|
|
|
|
SetCompressor ${ this.options.solid ? '/SOLID' : '' } ${ this.options.compression }
|
|
|
-OutFile "${ win32.normalize(resolve(this.options.output)) }"
|
|
|
+OutFile "\${_OUTPUT}"
|
|
|
|
|
|
-InstallDir "$LOCALAPPDATA\\${ this.options.appName }"
|
|
|
-InstallDirRegKey HKCU "Software\\${ this.options.appName }" "InstallDir"
|
|
|
+InstallDir "${ this.options.installDirectory }"
|
|
|
+InstallDirRegKey HKCU "Software\\\${_APPNAME}" "InstallDir"
|
|
|
|
|
|
RequestExecutionLevel user
|
|
|
XPStyle on`;
|
|
|
}
|
|
|
|
|
|
- protected async makeStringsSection(): Promise<string> {
|
|
|
- return `${ NsisComposer.DIVIDER }
|
|
|
-#
|
|
|
-# Strings
|
|
|
-#
|
|
|
-${ NsisComposer.DIVIDER }
|
|
|
-
|
|
|
-# FIXME: More translations.
|
|
|
-
|
|
|
-LangString CREATE_DESKTOP_SHORTCUT 1033 "Create Desktop Shortcut"
|
|
|
-LangString CREATE_DESKTOP_SHORTCUT 2052 "创建桌面快捷方式"
|
|
|
-LangString CREATE_DESKTOP_SHORTCUT 1028 "建立桌面捷徑"
|
|
|
-
|
|
|
-LangString INSTALLING 1033 "Installing"
|
|
|
-LangString INSTALLING 2052 "正在安装"
|
|
|
-LangString INSTALLING 1028 "安裝中"
|
|
|
-`;
|
|
|
- }
|
|
|
-
|
|
|
- protected async makeModernUISection(): Promise<string> {
|
|
|
+ protected async makeModernUI(): Promise<string> {
|
|
|
return `${ NsisComposer.DIVIDER }
|
|
|
#
|
|
|
# Modern UI
|
|
|
@@ -152,11 +158,11 @@ ${ NsisComposer.DIVIDER }
|
|
|
!include "MUI2.nsh"
|
|
|
|
|
|
Function CreateDesktopShortcut
|
|
|
- CreateShortcut "$DESKTOP\\${ this.options.appName }.lnk" "$INSTDIR\\${ this.options.appName }.exe"
|
|
|
+ CreateShortcut "$DESKTOP\\\${_APPNAME}.lnk" "$INSTDIR\\\${_APPNAME}.exe"
|
|
|
FunctionEnd
|
|
|
|
|
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
|
|
|
-!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\\${ this.options.appName }"
|
|
|
+!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\\\${_APPNAME}"
|
|
|
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenuFolder"
|
|
|
|
|
|
!define MUI_FINISHPAGE_SHOWREADME ""
|
|
|
@@ -165,7 +171,7 @@ FunctionEnd
|
|
|
|
|
|
Var StartMenuFolder
|
|
|
|
|
|
-!define MUI_FINISHPAGE_RUN "$INSTDIR\\${ this.options.appName }.exe"
|
|
|
+!define MUI_FINISHPAGE_RUN "$INSTDIR\\\${_APPNAME}.exe"
|
|
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
|
@@ -191,22 +197,22 @@ ${
|
|
|
}`;
|
|
|
}
|
|
|
|
|
|
- protected async makeVersionSection(): Promise<string> {
|
|
|
+ protected async makeVersioning(): Promise<string> {
|
|
|
return `${ NsisComposer.DIVIDER }
|
|
|
#
|
|
|
-# Versions
|
|
|
+# Versioning
|
|
|
#
|
|
|
${ NsisComposer.DIVIDER }
|
|
|
|
|
|
-VIProductVersion "${ this.fixedVersion }"
|
|
|
-VIAddVersionKey /LANG=0 "ProductName" "${ this.options.appName }"
|
|
|
-VIAddVersionKey /LANG=0 "CompanyName" "${ this.options.companyName }"
|
|
|
-VIAddVersionKey /LANG=0 "FileDescription" "${ this.options.description }"
|
|
|
-VIAddVersionKey /LANG=0 "FileVersion" "${ this.fixedVersion }"
|
|
|
-VIAddVersionKey /LANG=0 "LegalCopyright" "${ this.options.copyright }"`;
|
|
|
+VIProductVersion "\${_VERSION}"
|
|
|
+VIAddVersionKey /LANG=0 "ProductName" "\${_APPNAME}"
|
|
|
+VIAddVersionKey /LANG=0 "CompanyName" "\${_COMPANYNAME}"
|
|
|
+VIAddVersionKey /LANG=0 "FileDescription" "$\{_DESCRIPTION}"
|
|
|
+VIAddVersionKey /LANG=0 "FileVersion" "\${_VERSION}"
|
|
|
+VIAddVersionKey /LANG=0 "LegalCopyright" "\${_COPYRIGHT}"`;
|
|
|
}
|
|
|
|
|
|
- protected async makeHookSection(): Promise<string> {
|
|
|
+ protected async makeHooks(): Promise<string> {
|
|
|
return `${ NsisComposer.DIVIDER }
|
|
|
#
|
|
|
# Hooks
|
|
|
@@ -236,14 +242,14 @@ Section -Install
|
|
|
SetShellVarContext current
|
|
|
SetOverwrite ifnewer
|
|
|
|
|
|
-WriteRegStr HKCU "Software\\${ this.options.appName }" "InstallDir" "$INSTDIR"
|
|
|
+WriteRegStr HKCU "Software\\\${_APPNAME}" "InstallDir" "$INSTDIR"
|
|
|
|
|
|
${ await this.makeInstallerFiles() }
|
|
|
|
|
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN "Application"
|
|
|
|
|
|
CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"
|
|
|
- CreateShortcut "$SMPROGRAMS\\$StartMenuFolder\\${ this.options.appName }.lnk" "$INSTDIR\\${ this.options.appName }.exe"
|
|
|
+ CreateShortcut "$SMPROGRAMS\\$StartMenuFolder\\\${_APPNAME}.lnk" "$INSTDIR\\\${_APPNAME}.exe"
|
|
|
CreateShortcut "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk" "$INSTDIR\\Uninstall.exe"
|
|
|
|
|
|
!insertmacro MUI_STARTMENU_WRITE_END
|
|
|
@@ -267,13 +273,13 @@ RMDir /r "$INSTDIR"
|
|
|
|
|
|
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $StartMenuFolder
|
|
|
|
|
|
-Delete "$SMPROGRAMS\\$StartMenuFolder\\${ this.options.appName }.lnk"
|
|
|
+Delete "$SMPROGRAMS\\$StartMenuFolder\\\${_APPNAME}.lnk"
|
|
|
Delete "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk"
|
|
|
RMDir "$SMPROGRAMS\\$StartMenuFolder"
|
|
|
|
|
|
-Delete "$DESKTOP\\${ this.options.appName }.lnk"
|
|
|
+Delete "$DESKTOP\\\${_APPNAME}.lnk"
|
|
|
|
|
|
-DeleteRegKey HKCU "Software\\${ this.options.appName }"
|
|
|
+DeleteRegKey HKCU "Software\\\${_APPNAME}"
|
|
|
|
|
|
SectionEnd`;
|
|
|
}
|