Socket
Socket
Sign inDemoInstall

cordova-plugin-ionic

Package Overview
Dependencies
Maintainers
7
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-ionic - npm Package Compare versions

Comparing version 5.4.8-0 to 5.4.8-1

174

dist/common.js

@@ -85,3 +85,3 @@ "use strict";

this.MANIFEST_FILE = 'pro-manifest.json';
this.PLUGIN_VERSION = '5.4.8-0';
this.PLUGIN_VERSION = '5.4.8-1';
this.appInfo = appInfo;

@@ -97,3 +97,3 @@ this._savedPreferences = preferences;

// make sure we're not going to redirect to a stale version
return [4 /*yield*/, this.cleanCurrentVersionIfStale()];
return [4 /*yield*/, this.cleanupStaleVersions()];
case 1:

@@ -262,3 +262,3 @@ // make sure we're not going to redirect to a stale version

case 3:
if (!resp.ok) return [3 /*break*/, 8];
if (!resp.ok) return [3 /*break*/, 6];
checkForUpdateResp = jsonResp.data;

@@ -279,21 +279,15 @@ if (!(checkForUpdateResp.available && checkForUpdateResp.url && checkForUpdateResp.snapshot && checkForUpdateResp.build)) return [3 /*break*/, 5];

_d.sent();
return [3 /*break*/, 7];
case 5:
delete prefs.availableUpdate;
return [4 /*yield*/, this._savePrefs(prefs)];
_d.label = 5;
case 5: return [2 /*return*/, checkForUpdateResp];
case 6:
_d.sent();
_d.label = 7;
case 7: return [2 /*return*/, checkForUpdateResp];
case 8:
_a = Error.bind;
_b = "Error Status " + resp.status + ": ";
if (!jsonResp) return [3 /*break*/, 9];
if (!jsonResp) return [3 /*break*/, 7];
_c = jsonResp.error.message;
return [3 /*break*/, 11];
case 9: return [4 /*yield*/, resp.text()];
case 10:
return [3 /*break*/, 9];
case 7: return [4 /*yield*/, resp.text()];
case 8:
_c = _d.sent();
_d.label = 11;
case 11: throw new (_a.apply(Error, [void 0, _b + (_c)]))();
_d.label = 9;
case 9: throw new (_a.apply(Error, [void 0, _b + (_c)]))();
}

@@ -498,7 +492,5 @@ });

switch (_a.label) {
case 0: return [4 /*yield*/, this.checkForUpdate()];
case 1:
_a.sent();
case 0:
prefs = this._savedPreferences;
if (!(prefs.availableUpdate && prefs.availableUpdate.state === UpdateState.Ready)) return [3 /*break*/, 3];
if (!(prefs.availableUpdate && prefs.availableUpdate.state === UpdateState.Ready)) return [3 /*break*/, 2];
prefs.currentVersionId = prefs.availableUpdate.versionId;

@@ -508,13 +500,13 @@ prefs.currentBuildId = prefs.availableUpdate.buildId;

return [4 /*yield*/, this._savePrefs(prefs)];
case 1:
_a.sent();
_a.label = 2;
case 2:
_a.sent();
_a.label = 3;
if (!prefs.currentVersionId) return [3 /*break*/, 7];
return [4 /*yield*/, this._isRunningVersion(prefs.currentVersionId)];
case 3:
if (!prefs.currentVersionId) return [3 /*break*/, 8];
return [4 /*yield*/, this._isRunningVersion(prefs.currentVersionId)];
case 4:
if (!_a.sent()) return [3 /*break*/, 7];
if (!_a.sent()) return [3 /*break*/, 6];
console.log("Already running version " + prefs.currentVersionId);
return [4 /*yield*/, this._savePrefs(prefs)];
case 5:
case 4:
_a.sent();

@@ -524,6 +516,6 @@ channel.onIonicProReady.fire();

return [4 /*yield*/, this.cleanupVersions()];
case 6:
case 5:
_a.sent();
return [2 /*return*/, false];
case 7:
case 6:
// Is the current version on the device?

@@ -538,3 +530,3 @@ if (!(prefs.currentVersionId in prefs.updates)) {

return [2 /*return*/, true];
case 8:
case 7:
channel.onIonicProReady.fire();

@@ -547,3 +539,3 @@ return [2 /*return*/, false];

// compare an update to the current version using both name & code
IonicDeployImpl.prototype.isCurrentVersion = function (update) {
IonicDeployImpl.prototype.isUpdateForCurrentBinary = function (update) {
var currentVersionCode = this._savedPreferences.binaryVersionCode;

@@ -555,29 +547,43 @@ var currentVersionName = this._savedPreferences.binaryVersionName;

};
IonicDeployImpl.prototype.cleanCurrentVersionIfStale = function () {
IonicDeployImpl.prototype.isUpdateCurrentlyInstalled = function (update) {
return this._savedPreferences.currentVersionId === update.versionId;
};
IonicDeployImpl.prototype.cleanupStaleVersions = function () {
return __awaiter(this, void 0, void 0, function () {
var prefs, _a, versionId;
var updates, prefs, _i, updates_1, update, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
updates = this.getStoredUpdates();
prefs = this._savedPreferences;
if (!prefs.currentVersionId) return [3 /*break*/, 4];
_a = !this.isCurrentVersion(prefs.updates[prefs.currentVersionId]);
if (!_a) return [3 /*break*/, 2];
return [4 /*yield*/, this._isRunningVersion(prefs.currentVersionId)];
_i = 0, updates_1 = updates;
_b.label = 1;
case 1:
if (!(_i < updates_1.length)) return [3 /*break*/, 6];
update = updates_1[_i];
_a = !this.isUpdateForCurrentBinary(update);
if (!_a) return [3 /*break*/, 3];
return [4 /*yield*/, this._isRunningVersion(update.versionId)];
case 2:
_a = !(_b.sent());
_b.label = 2;
case 2:
if (!_a) return [3 /*break*/, 4];
console.log("Update " + prefs.currentVersionId + " was built for different binary version removing update from device" +
("Update binaryVersionName: " + prefs.updates[prefs.currentVersionId].binaryVersionName + ", Device binaryVersionName " + prefs.binaryVersionName) +
("Update binaryVersionCode: " + prefs.updates[prefs.currentVersionId].binaryVersionCode + ", Device binaryVersionCode " + prefs.binaryVersionCode));
versionId = prefs.currentVersionId;
// NOTE: deleting pref.currentVersionId here to fool deleteVersionById into deleting it
delete prefs.currentVersionId;
return [4 /*yield*/, this.deleteVersionById(versionId)];
_b.label = 3;
case 3:
if (!_a) return [3 /*break*/, 5];
console.log("Update " + update.versionId + " was built for different binary version removing update from device" +
("Update binaryVersionName: " + update.binaryVersionName + ", Device binaryVersionName " + prefs.binaryVersionName) +
("Update binaryVersionCode: " + update.binaryVersionCode + ", Device binaryVersionCode " + prefs.binaryVersionCode));
// This is no longer necessary for this function, but a previous version of the code
// deleted `prefs.currentVersionId` near initialization so other code may rely on still
// deleting `prefs.currentVersionId`.
if (this.isUpdateCurrentlyInstalled(update)) {
delete prefs.currentVersionId;
}
return [4 /*yield*/, this.deleteVersionById(update.versionId)];
case 4:
_b.sent();
_b.label = 4;
case 4: return [2 /*return*/];
_b.label = 5;
case 5:
_i++;
return [3 /*break*/, 1];
case 6: return [2 /*return*/];
}

@@ -717,5 +723,2 @@ });

prefs = this._savedPreferences;
if (prefs.currentVersionId === versionId) {
throw Error("Can't delete version with id: " + versionId + " as it is the current version.");
}
delete prefs.updates[versionId];

@@ -736,3 +739,3 @@ return [4 /*yield*/, this._savePrefs(prefs)];

IonicDeployImpl.prototype.getStoredUpdates = function () {
// get an array of stored updates minus current deployed one
// get an array of stored updates
var prefs = this._savedPreferences;

@@ -742,6 +745,3 @@ var updates = [];

var versionId = _a[_i];
// don't clean up the current version
if (versionId !== prefs.currentVersionId) {
updates.push(prefs.updates[versionId]);
}
updates.push(prefs.updates[versionId]);
}

@@ -752,43 +752,27 @@ return updates;

return __awaiter(this, void 0, void 0, function () {
var prefs, updates, _i, updates_1, update, _a, updates_2, update;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
var prefs, updatesToDelete, _i, updatesToDelete_1, update;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.cleanupStaleVersions()];
case 1:
_a.sent();
prefs = this._savedPreferences;
updates = this.getStoredUpdates();
_i = 0, updates_1 = updates;
_b.label = 1;
case 1:
if (!(_i < updates_1.length)) return [3 /*break*/, 4];
update = updates_1[_i];
if (!!this.isCurrentVersion(update)) return [3 /*break*/, 3];
console.log("Update " + update.versionId + " was built for different binary version removing update from device" +
("Update binaryVersionName: " + update.binaryVersionName + ", Device binaryVersionName " + prefs.binaryVersionName) +
("Update binaryVersionCode: " + update.binaryVersionCode + ", Device binaryVersionCode " + prefs.binaryVersionCode));
updatesToDelete = this.getStoredUpdates().filter(function (a) { return !_this.isUpdateCurrentlyInstalled(a); })
.sort(function (a, b) { return a.lastUsed.localeCompare(b.lastUsed); })
.reverse()
.slice(prefs.maxVersions);
_i = 0, updatesToDelete_1 = updatesToDelete;
_a.label = 2;
case 2:
if (!(_i < updatesToDelete_1.length)) return [3 /*break*/, 5];
update = updatesToDelete_1[_i];
return [4 /*yield*/, this.deleteVersionById(update.versionId)];
case 2:
_b.sent();
_b.label = 3;
case 3:
_a.sent();
_a.label = 4;
case 4:
_i++;
return [3 /*break*/, 1];
case 4:
// clean down to Max Updates stored
updates = this.getStoredUpdates();
updates = updates.sort(function (a, b) { return a.lastUsed.localeCompare(b.lastUsed); });
updates = updates.reverse();
updates = updates.slice(prefs.maxVersions);
_a = 0, updates_2 = updates;
_b.label = 5;
case 5:
if (!(_a < updates_2.length)) return [3 /*break*/, 8];
update = updates_2[_a];
return [4 /*yield*/, this.deleteVersionById(update.versionId)];
case 6:
_b.sent();
_b.label = 7;
case 7:
_a++;
return [3 /*break*/, 5];
case 8: return [2 /*return*/];
return [3 /*break*/, 2];
case 5: return [2 /*return*/];
}

@@ -795,0 +779,0 @@ });

{
"name": "cordova-plugin-ionic",
"version": "5.4.8-0",
"version": "5.4.8-1",
"cordova": {

@@ -5,0 +5,0 @@ "id": "cordova-plugin-ionic",

@@ -73,3 +73,3 @@ /// <reference types="cordova" />

private MANIFEST_FILE = 'pro-manifest.json';
public PLUGIN_VERSION = '5.4.8-0';
public PLUGIN_VERSION = '5.4.8-1';

@@ -83,3 +83,3 @@ constructor(appInfo: IAppInfo, preferences: ISavedPreferences) {

// make sure we're not going to redirect to a stale version
await this.cleanCurrentVersionIfStale();
await this.cleanupStaleVersions();
const isOnline = navigator && navigator.onLine;

@@ -217,5 +217,2 @@ if (!isOnline) {

await this._savePrefs(prefs);
} else {
delete prefs.availableUpdate;
await this._savePrefs(prefs);
}

@@ -335,5 +332,2 @@ return checkForUpdateResp;

async reloadApp(): Promise<boolean> {
await this.checkForUpdate();
const prefs = this._savedPreferences;

@@ -351,3 +345,2 @@

if (prefs.currentVersionId) {
// Are we already running the deployed version?

@@ -381,3 +374,3 @@ if (await this._isRunningVersion(prefs.currentVersionId)) {

// compare an update to the current version using both name & code
private isCurrentVersion(update: IAvailableUpdate) {
private isUpdateForCurrentBinary(update: IAvailableUpdate) {
const currentVersionCode = this._savedPreferences.binaryVersionCode;

@@ -390,16 +383,27 @@ const currentVersionName = this._savedPreferences.binaryVersionName;

private async cleanCurrentVersionIfStale() {
private isUpdateCurrentlyInstalled(update: IAvailableUpdate) {
return this._savedPreferences.currentVersionId === update.versionId;
}
private async cleanupStaleVersions() {
const updates = this.getStoredUpdates();
const prefs = this._savedPreferences;
// Is the current version built from a previous binary?
if (prefs.currentVersionId) {
if (!this.isCurrentVersion(prefs.updates[prefs.currentVersionId]) && !(await this._isRunningVersion(prefs.currentVersionId))) {
for (const update of updates) {
// Is the version built from a previous binary?
if (!this.isUpdateForCurrentBinary(update) && !(await this._isRunningVersion(update.versionId))) {
console.log(
`Update ${prefs.currentVersionId} was built for different binary version removing update from device` +
`Update binaryVersionName: ${prefs.updates[prefs.currentVersionId].binaryVersionName}, Device binaryVersionName ${prefs.binaryVersionName}` +
`Update binaryVersionCode: ${prefs.updates[prefs.currentVersionId].binaryVersionCode}, Device binaryVersionCode ${prefs.binaryVersionCode}`
`Update ${update.versionId} was built for different binary version removing update from device` +
`Update binaryVersionName: ${update.binaryVersionName}, Device binaryVersionName ${prefs.binaryVersionName}` +
`Update binaryVersionCode: ${update.binaryVersionCode}, Device binaryVersionCode ${prefs.binaryVersionCode}`
);
const versionId = prefs.currentVersionId;
// NOTE: deleting pref.currentVersionId here to fool deleteVersionById into deleting it
delete prefs.currentVersionId;
await this.deleteVersionById(versionId);
// This is no longer necessary for this function, but a previous version of the code
// deleted `prefs.currentVersionId` near initialization so other code may rely on still
// deleting `prefs.currentVersionId`.
if (this.isUpdateCurrentlyInstalled(update)) {
delete prefs.currentVersionId;
}
await this.deleteVersionById(update.versionId);
}

@@ -484,6 +488,2 @@ }

if (prefs.currentVersionId === versionId) {
throw Error(`Can't delete version with id: ${versionId} as it is the current version.`);
}
delete prefs.updates[versionId];

@@ -499,10 +499,7 @@ await this._savePrefs(prefs);

private getStoredUpdates() {
// get an array of stored updates minus current deployed one
// get an array of stored updates
const prefs = this._savedPreferences;
const updates = [];
for (const versionId of Object.keys(prefs.updates)) {
// don't clean up the current version
if (versionId !== prefs.currentVersionId) {
updates.push(prefs.updates[versionId]);
}
updates.push(prefs.updates[versionId]);
}

@@ -513,24 +510,15 @@ return updates;

private async cleanupVersions() {
await this.cleanupStaleVersions();
const prefs = this._savedPreferences;
// get updates which now have no stale versions
// filter out the current running version
// clean down to Max Updates stored
let updates = this.getStoredUpdates();
// First clean stale versions
for (const update of updates) {
if (!this.isCurrentVersion(update)) {
console.log(
`Update ${update.versionId} was built for different binary version removing update from device` +
`Update binaryVersionName: ${update.binaryVersionName}, Device binaryVersionName ${prefs.binaryVersionName}` +
`Update binaryVersionCode: ${update.binaryVersionCode}, Device binaryVersionCode ${prefs.binaryVersionCode}`
);
await this.deleteVersionById(update.versionId);
}
}
const updatesToDelete = this.getStoredUpdates().filter((a) => !this.isUpdateCurrentlyInstalled(a))
.sort((a, b) => a.lastUsed.localeCompare(b.lastUsed))
.reverse()
.slice(prefs.maxVersions);
// clean down to Max Updates stored
updates = this.getStoredUpdates();
updates = updates.sort((a, b) => a.lastUsed.localeCompare(b.lastUsed));
updates = updates.reverse();
updates = updates.slice(prefs.maxVersions);
for (const update of updates) {
for (const update of updatesToDelete) {
await this.deleteVersionById(update.versionId);

@@ -537,0 +525,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc