cordova-plugin-hot-updates 2.0.0 โ†’ 2.1.1

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,239 @@
1
+ # Changelog
2
+
3
+ All notable changes to cordova-plugin-hot-updates will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.1.0] - 2025-11-04
9
+
10
+ ### ๐Ÿ› ๏ธ Fixed
11
+
12
+ - **getUpdate() duplicate downloads**: Added check for already installed version - `getUpdate()` now returns success without re-downloading if the requested version is already installed
13
+ - **Duplicate code**: Removed duplicate `setBool:YES forKey:kPendingUpdateReady` call in `saveDownloadedUpdate()`
14
+
15
+ ### ๐Ÿงน Improved
16
+
17
+ - **Cleaner logs**: Removed all emoji and debug messages from native code - logs are now professional and suitable for production
18
+ - **Code cleanup**: Removed 3 unused internal methods (~80 lines of dead code):
19
+ - `removeVersionFromIgnoreList()`
20
+ - `isVersionIgnored()`
21
+ - `compareVersion:withVersion:`
22
+ - **Updated documentation**: Header comment now accurately reflects frontend-controlled architecture
23
+
24
+ ### ๐Ÿ“Š Technical Details
25
+
26
+ **Files changed**: 1 (HotUpdates.m)
27
+ - Added: ~15 lines
28
+ - Removed: ~80 lines
29
+ - Methods removed: 3
30
+
31
+ **No breaking changes** - API remains fully compatible with v2.0.0
32
+
33
+ ---
34
+
35
+ ## [2.0.0] - 2025-10-30
36
+
37
+ ### ๐Ÿ”ฅ Breaking Changes
38
+
39
+ - **Rollback behavior changed**: After successful rollback, `previousVersion` is now cleared to prevent infinite rollback loops. This means you can only rollback once without performing a new update first.
40
+
41
+ ### โœจ Added
42
+
43
+ - **Loop Prevention**: Added protection against infinite update/rollback cycles
44
+ - `forceUpdate` now rejects attempts to install already installed version (error: `version_already_installed`)
45
+ - `rollback` validates that previous version differs from current (error: `same_version`)
46
+ - `rollback` clears `previousVersion` metadata after successful rollback
47
+
48
+ - **Enhanced Error Codes**: 13 detailed error codes for better error handling
49
+ - **forceUpdate**: 9 error codes (`version_already_installed`, `version_ignored`, `version_incompatible`, `download_failed`, `http_error`, `unzip_failed`, `invalid_package`, `install_failed`, `Download already in progress`)
50
+ - **rollback**: 4 error codes (`no_previous_version`, `previous_files_missing`, `same_version`, `file_operation_failed`)
51
+
52
+ - **Improved Version Checking**: `getVersionInfo` now properly validates all conditions for rollback availability
53
+ - Checks: folder exists + metadata exists + versions are different
54
+ - New fields: `rollbackAvailable` (folder exists), `rollbackReady` (all conditions met)
55
+
56
+ - **Enhanced API Responses**:
57
+ - `rollback` success response includes `canRollbackAgain: false` field
58
+ - `rollback` error response includes detailed error information: `error`, `message`, `currentVersion`, `previousVersion`, `canRollback`, `hasPreviousMetadata`
59
+ - `forceUpdate` error includes `currentVersion` and `requestedVersion` for `version_already_installed` error
60
+
61
+ ### ๐Ÿ› ๏ธ Fixed
62
+
63
+ - Fixed infinite rollback loop caused by version metadata swapping
64
+ - Fixed `canRollback` incorrectly returning `true` when versions are identical
65
+ - Fixed ability to install the same version multiple times
66
+ - Fixed rollback not detecting corrupted metadata
67
+
68
+ ### ๐Ÿ“ Changed
69
+
70
+ - Reduced excessive debug logging, keeping only essential logs
71
+ - Improved log clarity and consistency across all methods
72
+ - Metadata management now uses strict version validation
73
+
74
+ ### ๐Ÿ”’ Security
75
+
76
+ - Added validation to prevent rollback to same version (potential attack vector)
77
+ - Enhanced version comparison logic to prevent bypass attempts
78
+
79
+ ## [1.0.0] - 2025-10-27
80
+
81
+ ### โœจ Initial Release
82
+
83
+ - Frontend-controlled WebView Reload approach
84
+ - Automatic background update checking
85
+ - Force update capability with instant WebView reload
86
+ - Rollback mechanism with automatic backup
87
+ - IgnoreList for blocking problematic versions
88
+ - Canary system for version verification
89
+ - Semantic version comparison
90
+ - minAppVersion compatibility checking
91
+ - Auto-update toggle (disabled by default)
92
+ - First launch detection and handling
93
+ - Support for iOS 11.2+
94
+
95
+ ---
96
+
97
+ ## Migration Guide: 1.0.0 โ†’ 2.0.0
98
+
99
+ ### Breaking Changes
100
+
101
+ **1. Rollback Behavior**
102
+
103
+ **Before (v1.0.0):**
104
+ ```
105
+ Installed: 2.7.8, Previous: 2.7.7
106
+ rollback() โ†’ Installed: 2.7.7, Previous: 2.7.8 โš ๏ธ (could create infinite loop)
107
+ ```
108
+
109
+ **After (v2.0.0):**
110
+ ```
111
+ Installed: 2.7.8, Previous: 2.7.7
112
+ rollback() โ†’ Installed: 2.7.7, Previous: nil โœ… (loop prevented)
113
+ ```
114
+
115
+ ### What You Need to Update
116
+
117
+ **1. Error Handling for forceUpdate**
118
+
119
+ Add handler for new `version_already_installed` error:
120
+
121
+ ```javascript
122
+ window.HotUpdates.forceUpdate(data, function(result) {
123
+ if (result.error === 'version_already_installed') {
124
+ // New in v2.0.0: Handle already installed version
125
+ showNotification('This version is already installed');
126
+ return;
127
+ }
128
+ // ... rest of error handling
129
+ });
130
+ ```
131
+
132
+ **2. Error Handling for rollback**
133
+
134
+ Update rollback error handling with new detailed errors:
135
+
136
+ ```javascript
137
+ window.HotUpdates.rollback(function(result) {
138
+ if (!result.success) {
139
+ // New in v2.0.0: Detailed error codes
140
+ switch(result.error) {
141
+ case 'no_previous_version':
142
+ showError('No previous version to rollback to');
143
+ break;
144
+ case 'previous_files_missing':
145
+ showError('Previous version files not found');
146
+ break;
147
+ case 'same_version':
148
+ showError('Cannot rollback to the same version');
149
+ break;
150
+ case 'file_operation_failed':
151
+ showError('Rollback failed');
152
+ break;
153
+ }
154
+ }
155
+ });
156
+ ```
157
+
158
+ **3. UI Updates for Rollback**
159
+
160
+ Check `canRollbackAgain` field after rollback:
161
+
162
+ ```javascript
163
+ window.HotUpdates.rollback(function(result) {
164
+ if (result.success) {
165
+ console.log('Rollback successful');
166
+ console.log('Can rollback again:', result.canRollbackAgain); // Always false in v2.0.0
167
+
168
+ // Hide rollback button after successful rollback
169
+ if (!result.canRollbackAgain) {
170
+ hideRollbackButton();
171
+ }
172
+ }
173
+ });
174
+ ```
175
+
176
+ **4. Version Info Checks**
177
+
178
+ Use improved `canRollback` field:
179
+
180
+ ```javascript
181
+ window.HotUpdates.getVersionInfo(function(info) {
182
+ // v2.0.0: More accurate rollback availability check
183
+ if (info.canRollback) {
184
+ // All conditions met: folder + metadata + different versions
185
+ enableRollbackButton();
186
+ } else {
187
+ disableRollbackButton();
188
+ }
189
+
190
+ // New fields in v2.0.0:
191
+ console.log('Rollback folder exists:', info.rollbackAvailable);
192
+ console.log('Rollback ready:', info.rollbackReady);
193
+ });
194
+ ```
195
+
196
+ ### Testing After Migration
197
+
198
+ Run these tests to ensure v2.0.0 works correctly:
199
+
200
+ ```javascript
201
+ // Test 1: Prevent duplicate installation
202
+ window.HotUpdates.getCurrentVersion(function(current) {
203
+ window.HotUpdates.forceUpdate({
204
+ url: 'http://example.com/update.zip',
205
+ version: current // Same as current!
206
+ }, function(result) {
207
+ // Should return error: version_already_installed โœ…
208
+ console.assert(result.error === 'version_already_installed');
209
+ });
210
+ });
211
+
212
+ // Test 2: Rollback loop prevention
213
+ window.HotUpdates.forceUpdate({url: '...', version: '2.7.8'}, function(r1) {
214
+ if (r1.status === 'installed') {
215
+ window.HotUpdates.rollback(function(r2) {
216
+ if (r2.success) {
217
+ // First rollback: should succeed โœ…
218
+ window.HotUpdates.rollback(function(r3) {
219
+ // Second rollback: should fail with no_previous_version โœ…
220
+ console.assert(!r3.success);
221
+ console.assert(r3.error === 'no_previous_version');
222
+ });
223
+ }
224
+ });
225
+ }
226
+ });
227
+ ```
228
+
229
+ ### Performance Impact
230
+
231
+ - **No performance degradation**: All changes are optimizations
232
+ - **Reduced log output**: Less console spam in production
233
+ - **Faster error detection**: Version checks happen earlier
234
+
235
+ ### Support
236
+
237
+ - Documentation: [README.md](README.md)
238
+ - Issues: [GitHub Issues](https://github.com/vladimirDarksy/Cordova_hot_update/issues)
239
+ - Version comparison: [1.0.0...2.0.0](https://github.com/vladimirDarksy/Cordova_hot_update/compare/v1.0.0...v2.0.0)