cross-packer 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +151 -0
  3. package/README.zh-CN.md +151 -0
  4. package/dist/archive/ar.d.ts +12 -0
  5. package/dist/archive/seven-za.d.ts +32 -0
  6. package/dist/archive/tar.d.ts +30 -0
  7. package/dist/archive/zip-reader.d.ts +17 -0
  8. package/dist/asar/dependency/collect.d.ts +2 -0
  9. package/dist/asar/dependency/detector.d.ts +8 -0
  10. package/dist/asar/dependency/hoister.d.ts +27 -0
  11. package/dist/asar/dependency/utils.d.ts +59 -0
  12. package/dist/asar/fileset/matcher.d.ts +12 -0
  13. package/dist/asar/fileset/platform-fileset.d.ts +36 -0
  14. package/dist/asar/fileset/transformer.d.ts +2 -0
  15. package/dist/asar/fileset/unpack-detector.d.ts +10 -0
  16. package/dist/asar/fileset/walker.d.ts +14 -0
  17. package/dist/asar/pack.d.ts +23 -0
  18. package/dist/asar/packer/app-collector.d.ts +2 -0
  19. package/dist/asar/packer/collector.d.ts +18 -0
  20. package/dist/asar/packer/concurrency.d.ts +1 -0
  21. package/dist/asar/packer/integrity.d.ts +8 -0
  22. package/dist/asar/packer/nm-collector.d.ts +7 -0
  23. package/dist/asar/packer/stream-builder.d.ts +18 -0
  24. package/dist/cli.d.ts +2 -0
  25. package/dist/config/index.d.ts +97 -0
  26. package/dist/electron/dist-zip.d.ts +18 -0
  27. package/dist/electron/download.d.ts +21 -0
  28. package/dist/index.d.ts +11 -0
  29. package/dist/packer/common/app-update-yml.d.ts +5 -0
  30. package/dist/packer/common/extra-resources.d.ts +39 -0
  31. package/dist/packer/common/staging.d.ts +3 -0
  32. package/dist/packer/common/template.d.ts +2 -0
  33. package/dist/packer/linux/linux.d.ts +2 -0
  34. package/dist/packer/mac/mac.d.ts +23 -0
  35. package/dist/packer/win/nsis.d.ts +24 -0
  36. package/dist/packer/win/resedit.d.ts +5 -0
  37. package/dist/packer/win/toolchain.d.ts +8 -0
  38. package/dist/packer/win/win.d.ts +12 -0
  39. package/dist/pipeline/pipeline.d.ts +41 -0
  40. package/dist/pipeline/targets.d.ts +28 -0
  41. package/dist/shared/hash.d.ts +2 -0
  42. package/dist/shared/logger.d.ts +39 -0
  43. package/dist/shared/platform.d.ts +26 -0
  44. package/dist/shared/types.d.ts +68 -0
  45. package/dist/update/blockmap.d.ts +13 -0
  46. package/dist/update/metadata.d.ts +20 -0
  47. package/dist/update/version.d.ts +7 -0
  48. package/package.json +71 -0
  49. package/src/archive/ar.ts +41 -0
  50. package/src/archive/seven-za.ts +160 -0
  51. package/src/archive/tar.ts +142 -0
  52. package/src/archive/zip-reader.ts +61 -0
  53. package/src/asar/dependency/collect.ts +437 -0
  54. package/src/asar/dependency/detector.ts +73 -0
  55. package/src/asar/dependency/hoister.ts +714 -0
  56. package/src/asar/dependency/utils.ts +225 -0
  57. package/src/asar/fileset/matcher.ts +101 -0
  58. package/src/asar/fileset/platform-fileset.ts +416 -0
  59. package/src/asar/fileset/transformer.ts +154 -0
  60. package/src/asar/fileset/unpack-detector.ts +38 -0
  61. package/src/asar/fileset/walker.ts +115 -0
  62. package/src/asar/pack.ts +186 -0
  63. package/src/asar/packer/app-collector.ts +74 -0
  64. package/src/asar/packer/collector.ts +134 -0
  65. package/src/asar/packer/concurrency.ts +24 -0
  66. package/src/asar/packer/integrity.ts +53 -0
  67. package/src/asar/packer/nm-collector.ts +194 -0
  68. package/src/asar/packer/stream-builder.ts +723 -0
  69. package/src/cli.ts +182 -0
  70. package/src/config/index.ts +365 -0
  71. package/src/electron/dist-zip.ts +65 -0
  72. package/src/electron/download.ts +121 -0
  73. package/src/index.ts +14 -0
  74. package/src/packer/common/app-update-yml.ts +21 -0
  75. package/src/packer/common/extra-resources.ts +83 -0
  76. package/src/packer/common/staging.ts +33 -0
  77. package/src/packer/common/template.ts +24 -0
  78. package/src/packer/linux/linux.ts +329 -0
  79. package/src/packer/mac/mac.ts +495 -0
  80. package/src/packer/win/nsis.ts +244 -0
  81. package/src/packer/win/resedit.ts +60 -0
  82. package/src/packer/win/toolchain.ts +63 -0
  83. package/src/packer/win/win.ts +421 -0
  84. package/src/pipeline/pipeline.ts +149 -0
  85. package/src/pipeline/targets.ts +67 -0
  86. package/src/shared/hash.ts +15 -0
  87. package/src/shared/logger.ts +91 -0
  88. package/src/shared/platform.ts +41 -0
  89. package/src/shared/types.ts +82 -0
  90. package/src/update/blockmap.ts +247 -0
  91. package/src/update/metadata.ts +97 -0
  92. package/src/update/version.ts +59 -0
  93. package/templates/linux/app.desktop +11 -0
  94. package/templates/linux/control +9 -0
  95. package/templates/linux/postinst +10 -0
  96. package/templates/linux/postrm +8 -0
  97. package/templates/linux/preinst +49 -0
  98. package/templates/linux/prerm +43 -0
  99. package/templates/mac/Info.plist +18 -0
  100. package/templates/mac/app-update.yml +4 -0
  101. package/templates/win/nsis/README.md +51 -0
  102. package/templates/win/nsis/THIRD-PARTY-NOTICES.md +20 -0
  103. package/templates/win/nsis/assistedInstaller.nsh +154 -0
  104. package/templates/win/nsis/assistedMessages.yml +368 -0
  105. package/templates/win/nsis/common.nsh +147 -0
  106. package/templates/win/nsis/empty-license.txt +1 -0
  107. package/templates/win/nsis/include/FileAssociation.nsh +123 -0
  108. package/templates/win/nsis/include/StdUtils.nsh +496 -0
  109. package/templates/win/nsis/include/StrContains.nsh +48 -0
  110. package/templates/win/nsis/include/UAC.nsh +299 -0
  111. package/templates/win/nsis/include/allowOnlyOneInstallerInstance.nsh +164 -0
  112. package/templates/win/nsis/include/extractAppPackage.nsh +138 -0
  113. package/templates/win/nsis/include/getProcessInfo.nsh +157 -0
  114. package/templates/win/nsis/include/installUtil.nsh +248 -0
  115. package/templates/win/nsis/include/installer.nsh +247 -0
  116. package/templates/win/nsis/include/nsProcess.nsh +28 -0
  117. package/templates/win/nsis/include/webPackage.nsh +64 -0
  118. package/templates/win/nsis/installSection.nsh +110 -0
  119. package/templates/win/nsis/installer.nsi +132 -0
  120. package/templates/win/nsis/messages.yml +240 -0
  121. package/templates/win/nsis/multiUser.nsh +134 -0
  122. package/templates/win/nsis/multiUserUi.nsh +230 -0
  123. package/templates/win/nsis/oneClick.nsh +19 -0
  124. package/templates/win/nsis/portable.nsi +91 -0
  125. package/templates/win/nsis/uninstaller.nsh +263 -0
  126. package/templates/win/nsis-header.nsh +57 -0
@@ -0,0 +1,263 @@
1
+ Function un.checkAppRunning
2
+ !insertmacro CHECK_APP_RUNNING
3
+ FunctionEnd
4
+
5
+ Function un.onInit
6
+ SetOutPath $INSTDIR
7
+ ${LogSet} on
8
+
9
+ !insertmacro check64BitAndSetRegView
10
+
11
+ # Parse command line for /S flag and set silent mode
12
+ ${GetParameters} $R0
13
+ ${GetOptions} $R0 "/S" $R1
14
+ ${IfNot} ${Errors}
15
+ SetSilent silent
16
+ ${EndIf}
17
+
18
+ ${If} ${Silent}
19
+ call un.checkAppRunning
20
+ ${else}
21
+ !ifdef ONE_CLICK
22
+ MessageBox MB_OKCANCEL "$(areYouSureToUninstall)" IDOK +2
23
+ Quit
24
+
25
+ # one-click installer executes uninstall section in the silent mode, but we must show message dialog if silent mode was not explicitly set by user (using /S flag)
26
+ call un.checkAppRunning
27
+ SetSilent silent
28
+ !endif
29
+ ${endIf}
30
+
31
+ !insertmacro initMultiUser
32
+
33
+ !ifmacrodef customUnInit
34
+ !insertmacro customUnInit
35
+ !endif
36
+ FunctionEnd
37
+
38
+ Function un.atomicRMDir
39
+ Exch $R0
40
+ Push $R1
41
+ Push $R2
42
+ Push $R3
43
+
44
+ StrCpy $R3 "$INSTDIR$R0\*.*"
45
+ FindFirst $R1 $R2 $R3
46
+
47
+ loop:
48
+ StrCmp $R2 "" break
49
+
50
+ StrCmp $R2 "." continue
51
+ StrCmp $R2 ".." continue
52
+
53
+ IfFileExists "$INSTDIR$R0\$R2\*.*" isDir isNotDir
54
+
55
+ isDir:
56
+ CreateDirectory "$PLUGINSDIR\old-install$R0\$R2"
57
+
58
+ Push "$R0\$R2"
59
+ Call un.atomicRMDir
60
+ Pop $R3
61
+
62
+ ${if} $R3 != 0
63
+ Goto done
64
+ ${endIf}
65
+
66
+ Goto continue
67
+
68
+ isNotDir:
69
+ ClearErrors
70
+ Rename "$INSTDIR$R0\$R2" "$PLUGINSDIR\old-install$R0\$R2"
71
+
72
+ # Ignore errors when renaming ourselves.
73
+ StrCmp "$R0\$R2" "${UNINSTALL_FILENAME}" 0 +2
74
+ ClearErrors
75
+
76
+ IfErrors 0 +3
77
+ StrCpy $R3 "$INSTDIR$R0\$R2"
78
+ Goto done
79
+
80
+ continue:
81
+ FindNext $R1 $R2
82
+ Goto loop
83
+
84
+ break:
85
+ StrCpy $R3 0
86
+
87
+ done:
88
+ FindClose $R1
89
+
90
+ StrCpy $R0 $R3
91
+
92
+ Pop $R3
93
+ Pop $R2
94
+ Pop $R1
95
+ Exch $R0
96
+ FunctionEnd
97
+
98
+ Function un.restoreFiles
99
+ Exch $R0
100
+ Push $R1
101
+ Push $R2
102
+ Push $R3
103
+
104
+ StrCpy $R3 "$PLUGINSDIR\old-install$R0\*.*"
105
+ FindFirst $R1 $R2 $R3
106
+
107
+ loop:
108
+ StrCmp $R2 "" break
109
+
110
+ StrCmp $R2 "." continue
111
+ StrCmp $R2 ".." continue
112
+
113
+ IfFileExists "$INSTDIR$R0\$R2\*.*" isDir isNotDir
114
+
115
+ isDir:
116
+ CreateDirectory "$INSTDIR$R0\$R2"
117
+
118
+ Push "$R0\$R2"
119
+ Call un.restoreFiles
120
+ Pop $R3
121
+
122
+ Goto continue
123
+
124
+ isNotDir:
125
+ Rename "$PLUGINSDIR\old-install$R0\$R2" "$INSTDIR$R0\$R2"
126
+
127
+ continue:
128
+ FindNext $R1 $R2
129
+ Goto loop
130
+
131
+ break:
132
+ StrCpy $R0 0
133
+ FindClose $R1
134
+
135
+ Pop $R3
136
+ Pop $R2
137
+ Pop $R1
138
+ Exch $R0
139
+ FunctionEnd
140
+
141
+ !ifndef UNINSTALL_SECTION_NAME
142
+ !define UNINSTALL_SECTION_NAME "Uninstall"
143
+ !endif
144
+
145
+ Section "un.${UNINSTALL_SECTION_NAME}"
146
+ SectionIn RO
147
+ # for assisted installer we check it here to show progress
148
+ !ifndef ONE_CLICK
149
+ ${IfNot} ${Silent}
150
+ call un.checkAppRunning
151
+ ${endIf}
152
+ !endif
153
+
154
+ !insertmacro setLinkVars
155
+
156
+ !ifmacrodef customUnInstall
157
+ !insertmacro customUnInstall
158
+ !endif
159
+
160
+ # delete the installed files
161
+ !ifmacrodef customRemoveFiles
162
+ !insertmacro customRemoveFiles
163
+ !else
164
+ ${if} ${isUpdated}
165
+ CreateDirectory "$PLUGINSDIR\old-install"
166
+
167
+ Push ""
168
+ Call un.atomicRMDir
169
+ Pop $R0
170
+
171
+ ${if} $R0 != 0
172
+ DetailPrint "File is busy, aborting: $R0"
173
+
174
+ # Attempt to restore previous directory
175
+ Push ""
176
+ Call un.restoreFiles
177
+ Pop $R0
178
+
179
+ Abort `Can't rename "$INSTDIR" to "$PLUGINSDIR\old-install".`
180
+ ${endif}
181
+
182
+ ${endif}
183
+
184
+ # Move out of $INSTDIR so it can be removed
185
+ SetOutPath $TEMP
186
+ # Remove all files (or remaining shallow directories from the block above)
187
+ RMDir /r $INSTDIR
188
+ !endif
189
+
190
+ ${ifNot} ${isKeepShortcuts}
191
+ WinShell::UninstAppUserModelId "${APP_ID}"
192
+
193
+ !ifndef DO_NOT_CREATE_DESKTOP_SHORTCUT
194
+ WinShell::UninstShortcut "$oldDesktopLink"
195
+ Delete "$oldDesktopLink"
196
+ !endif
197
+
198
+ !ifndef DO_NOT_CREATE_START_MENU_SHORTCUT
199
+ WinShell::UninstShortcut "$oldStartMenuLink"
200
+
201
+ Delete "$oldStartMenuLink"
202
+ ReadRegStr $R1 SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" MenuDirectory
203
+ ${ifNot} $R1 == ""
204
+ RMDir "$SMPROGRAMS\$R1"
205
+ ${endIf}
206
+ !endif
207
+ ${endIf}
208
+
209
+ # refresh the desktop
210
+ System::Call 'shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
211
+
212
+ !ifmacrodef unregisterFileAssociations
213
+ !insertmacro unregisterFileAssociations
214
+ !endif
215
+
216
+ Var /GLOBAL isDeleteAppData
217
+ StrCpy $isDeleteAppData "0"
218
+
219
+ ClearErrors
220
+ ${GetParameters} $R0
221
+ ${GetOptions} $R0 "--delete-app-data" $R1
222
+ ${if} ${Errors}
223
+ !ifdef DELETE_APP_DATA_ON_UNINSTALL
224
+ ${ifNot} ${isUpdated}
225
+ StrCpy $isDeleteAppData "1"
226
+ ${endif}
227
+ !endif
228
+ ${else}
229
+ StrCpy $isDeleteAppData "1"
230
+ ${endIf}
231
+
232
+ ${if} $isDeleteAppData == "1"
233
+ # electron always uses per user app data
234
+ ${if} $installMode == "all"
235
+ SetShellVarContext current
236
+ ${endif}
237
+ RMDir /r "$APPDATA\${APP_FILENAME}"
238
+ !ifdef APP_PRODUCT_FILENAME
239
+ RMDir /r "$APPDATA\${APP_PRODUCT_FILENAME}"
240
+ !endif
241
+ # electron use package.json name for cache,indexdb etc.
242
+ !ifdef APP_PACKAGE_NAME
243
+ RMDir /r "$APPDATA\${APP_PACKAGE_NAME}"
244
+ !endif
245
+ ${if} $installMode == "all"
246
+ SetShellVarContext all
247
+ ${endif}
248
+ ${endif}
249
+
250
+ DeleteRegKey SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}"
251
+ !ifdef UNINSTALL_REGISTRY_KEY_2
252
+ DeleteRegKey SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY_2}"
253
+ !endif
254
+ DeleteRegKey SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}"
255
+
256
+ !ifdef ONE_CLICK
257
+ !insertmacro quitSuccess
258
+ !endif
259
+ SectionEnd
260
+
261
+ !ifmacrodef customUnInstallSection
262
+ !insertmacro customUnInstallSection
263
+ !endif
@@ -0,0 +1,57 @@
1
+ !include "${NSIS_STDLIBS_NSH_PATH}"
2
+ !addincludedir "${NSIS_INCLUDE_DIR}"
3
+ !addincludedir "${NSIS_TEMPLATES_DIR}"
4
+
5
+ !macro _isUpdated _a _b _t _f
6
+ ${StdUtils.TestParameter} $R9 "updated"
7
+ StrCmp "$R9" "true" `${_t}` `${_f}`
8
+ !macroend
9
+ !define isUpdated `"" isUpdated ""`
10
+
11
+ !macro _isForceRun _a _b _t _f
12
+ ${StdUtils.TestParameter} $R9 "force-run"
13
+ StrCmp "$R9" "true" `${_t}` `${_f}`
14
+ !macroend
15
+ !define isForceRun `"" isForceRun ""`
16
+
17
+ !macro _isKeepShortcuts _a _b _t _f
18
+ ${StdUtils.TestParameter} $R9 "keep-shortcuts"
19
+ StrCmp "$R9" "true" `${_t}` `${_f}`
20
+ !macroend
21
+ !define isKeepShortcuts `"" isKeepShortcuts ""`
22
+
23
+ !macro _isNoDesktopShortcut _a _b _t _f
24
+ ${StdUtils.TestParameter} $R9 "no-desktop-shortcut"
25
+ StrCmp "$R9" "true" `${_t}` `${_f}`
26
+ !macroend
27
+ !define isNoDesktopShortcut `"" isNoDesktopShortcut ""`
28
+
29
+ !macro _isDeleteAppData _a _b _t _f
30
+ ${StdUtils.TestParameter} $R9 "delete-app-data"
31
+ StrCmp "$R9" "true" `${_t}` `${_f}`
32
+ !macroend
33
+ !define isDeleteAppData `"" isDeleteAppData ""`
34
+
35
+ !macro _isForAllUsers _a _b _t _f
36
+ ${StdUtils.TestParameter} $R9 "allusers"
37
+ StrCmp "$R9" "true" `${_t}` `${_f}`
38
+ !macroend
39
+ !define isForAllUsers `"" isForAllUsers ""`
40
+
41
+ !macro _isForCurrentUser _a _b _t _f
42
+ ${StdUtils.TestParameter} $R9 "currentuser"
43
+ StrCmp "$R9" "true" `${_t}` `${_f}`
44
+ !macroend
45
+ !define isForCurrentUser `"" isForCurrentUser ""`
46
+
47
+ !macro addLangs
48
+ !insertmacro MUI_LANGUAGE "English"
49
+ !insertmacro MUI_LANGUAGE "SimpChinese"
50
+ !macroend
51
+
52
+ !addplugindir /${NSIS_PLUGIN_ARCH} "${NSIS_PLUGINS_DIR}"
53
+
54
+ !include "${NSIS_MESSAGES_NSH}"
55
+
56
+ !macro customMessageBox
57
+ !macroend