Added new status reporting.
This commit is contained in:
Родитель
657a35bac1
Коммит
73d7a5fec4
|
@ -37,7 +37,7 @@ var LocalPackage = (function (_super) {
|
|||
}
|
||||
var installError = function (error) {
|
||||
CodePushUtil.invokeErrorCallback(error, errorCallback);
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentFailed);
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentFailed, _this);
|
||||
};
|
||||
var newPackageLocation = LocalPackage.VersionsDir + "/" + this.packageHash;
|
||||
var donePackageFileCopy = function (deployDir) {
|
||||
|
@ -100,7 +100,7 @@ var LocalPackage = (function (_super) {
|
|||
}
|
||||
};
|
||||
var preInstallSuccess = function () {
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded);
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded, _this);
|
||||
invokeSuccessAndInstall();
|
||||
};
|
||||
var preInstallFailure = function (preInstallError) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
/// <reference path="../typings/codePush.d.ts" />
|
||||
/// <reference path="../typings/fileTransfer.d.ts" />
|
||||
/// <reference path="../typings/device.d.ts" />
|
||||
"use strict";
|
||||
var NativeAppInfo = require("./nativeAppInfo");
|
||||
var HttpRequester = require("./httpRequester");
|
||||
|
@ -19,7 +20,13 @@ var Sdk = (function () {
|
|||
Sdk.getAcquisitionManager = function (callback, userDeploymentKey) {
|
||||
var resolveManager = function (defaultInstance) {
|
||||
if (userDeploymentKey) {
|
||||
var customConfiguration = { deploymentKey: userDeploymentKey, serverUrl: Sdk.DefaultConfiguration.serverUrl, ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion };
|
||||
var customConfiguration = {
|
||||
deploymentKey: userDeploymentKey,
|
||||
serverUrl: Sdk.DefaultConfiguration.serverUrl,
|
||||
ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion,
|
||||
appVersion: Sdk.DefaultConfiguration.appVersion,
|
||||
clientUniqueId: Sdk.DefaultConfiguration.clientUniqueId
|
||||
};
|
||||
var customAcquisitionManager = new AcquisitionManager(new HttpRequester(), customConfiguration);
|
||||
callback(null, customAcquisitionManager);
|
||||
}
|
||||
|
@ -33,26 +40,34 @@ var Sdk = (function () {
|
|||
else {
|
||||
NativeAppInfo.getServerURL(function (serverError, serverURL) {
|
||||
NativeAppInfo.getDeploymentKey(function (depolymentKeyError, deploymentKey) {
|
||||
if (!serverURL || !deploymentKey) {
|
||||
callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
|
||||
}
|
||||
else {
|
||||
Sdk.DefaultConfiguration = { deploymentKey: deploymentKey, serverUrl: serverURL, ignoreAppVersion: false };
|
||||
Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
|
||||
resolveManager(Sdk.DefaultAcquisitionManager);
|
||||
}
|
||||
NativeAppInfo.getApplicationVersion(function (appVersionError, appVersion) {
|
||||
if (!serverURL || !deploymentKey || !appVersion) {
|
||||
callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
|
||||
}
|
||||
else {
|
||||
Sdk.DefaultConfiguration = {
|
||||
deploymentKey: deploymentKey,
|
||||
serverUrl: serverURL,
|
||||
ignoreAppVersion: false,
|
||||
appVersion: appVersion,
|
||||
clientUniqueId: device.uuid
|
||||
};
|
||||
Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
|
||||
resolveManager(Sdk.DefaultAcquisitionManager);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Sdk.reportStatus = function (status, callback) {
|
||||
Sdk.reportStatus = function (status, pkg, callback) {
|
||||
try {
|
||||
Sdk.getAcquisitionManager(function (error, acquisitionManager) {
|
||||
if (error) {
|
||||
callback && callback(error, null);
|
||||
}
|
||||
else {
|
||||
acquisitionManager.reportStatus(status, null, callback);
|
||||
acquisitionManager.reportStatusDeploy(pkg, status, callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
"cordova-ios"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"code-push": ">=1.0.0-beta",
|
||||
"code-push": ">=1.5.0-beta",
|
||||
"cordova-plugin-file-transfer": ">=1.3.0",
|
||||
"cordova-plugin-file": ">=3.0.0",
|
||||
"cordova-plugin-zip": ">=3.0.0",
|
||||
"cordova-plugin-dialogs": ">=1.1.1"
|
||||
"cordova-plugin-dialogs": ">=1.1.1",
|
||||
"cordova-plugin-device": ">=1.1.0"
|
||||
},
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "Licensed under the MIT license.",
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
<keywords>cordova,code,push</keywords>
|
||||
<repo>https://github.com/Microsoft/cordova-plugin-code-push.git</repo>
|
||||
|
||||
<dependency id="code-push" version=">=1.0.0-beta" />
|
||||
<dependency id="code-push" version=">=1.5.0-beta" />
|
||||
<dependency id="cordova-plugin-file-transfer" version=">=1.3.0" />
|
||||
<dependency id="cordova-plugin-file" version=">=3.0.0" />
|
||||
<dependency id="cordova-plugin-zip" version=">=3.0.0" />
|
||||
<dependency id="cordova-plugin-dialogs" version=">=1.1.1" />
|
||||
<dependency id="cordova-plugin-device" version=">=1.1.0" />
|
||||
|
||||
<js-module src="bin/www/codePush.js" name="codePush">
|
||||
<clobbers target="codePush" />
|
||||
|
|
|
@ -136,9 +136,11 @@ interface SuccessCallback<T> { (result?: T): void; }
|
|||
interface ErrorCallback { (error?: Error): void; }
|
||||
|
||||
interface Configuration {
|
||||
serverUrl: string;
|
||||
appVersion: string;
|
||||
clientUniqueId: string;
|
||||
deploymentKey: string;
|
||||
ignoreAppVersion?: boolean;
|
||||
serverUrl: string;
|
||||
ignoreAppVersion?: boolean
|
||||
}
|
||||
|
||||
declare class AcquisitionStatus {
|
||||
|
@ -149,7 +151,7 @@ declare class AcquisitionStatus {
|
|||
declare class AcquisitionManager {
|
||||
constructor(httpRequester: Http.Requester, configuration: Configuration);
|
||||
public queryUpdateWithCurrentPackage(currentPackage: IPackage, callback?: Callback<IRemotePackage | NativeUpdateNotification>): void;
|
||||
public reportStatus(status: string, message?: string, callback?: Callback<void>): void;
|
||||
public reportStatusDeploy(pkg?: IPackage, status?: string, callback?: Callback<void>): void;
|
||||
}
|
||||
|
||||
interface CodePushCordovaPlugin {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// Type definitions for Apache Cordova Device plugin.
|
||||
// Project: https://github.com/apache/cordova-plugin-device
|
||||
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
//
|
||||
// Copyright (c) Microsoft Open Technologies, Inc.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
/**
|
||||
* This plugin defines a global device object, which describes the device's hardware and software.
|
||||
* Although the object is in the global scope, it is not available until after the deviceready event.
|
||||
*/
|
||||
interface Device {
|
||||
/** Get the version of Cordova running on the device. */
|
||||
cordova: string;
|
||||
/**
|
||||
* The device.model returns the name of the device's model or product. The value is set
|
||||
* by the device manufacturer and may be different across versions of the same product.
|
||||
*/
|
||||
model: string;
|
||||
/** Get the device's operating system name. */
|
||||
platform: string;
|
||||
/** Get the device's Universally Unique Identifier (UUID). */
|
||||
uuid: string;
|
||||
/** Get the operating system version. */
|
||||
version: string;
|
||||
/** Get the device's manufacturer. */
|
||||
manufacturer: string;
|
||||
/** Whether the device is running on a simulator. */
|
||||
isVirtual: boolean;
|
||||
/** Get the device hardware serial number. */
|
||||
serial: string;}
|
||||
|
||||
declare var device: Device;
|
|
@ -61,7 +61,7 @@ class LocalPackage extends Package implements ILocalPackage {
|
|||
|
||||
var installError: ErrorCallback = (error: Error): void => {
|
||||
CodePushUtil.invokeErrorCallback(error, errorCallback);
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentFailed);
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentFailed, this);
|
||||
};
|
||||
|
||||
var newPackageLocation = LocalPackage.VersionsDir + "/" + this.packageHash;
|
||||
|
@ -128,7 +128,7 @@ class LocalPackage extends Package implements ILocalPackage {
|
|||
};
|
||||
|
||||
var preInstallSuccess = () => {
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded);
|
||||
Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded, this);
|
||||
/* package will be cleaned up after success, on the native side */
|
||||
invokeSuccessAndInstall();
|
||||
};
|
||||
|
|
35
www/sdk.ts
35
www/sdk.ts
|
@ -1,5 +1,6 @@
|
|||
/// <reference path="../typings/codePush.d.ts" />
|
||||
/// <reference path="../typings/fileTransfer.d.ts" />
|
||||
/// <reference path="../typings/device.d.ts" />
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -21,7 +22,13 @@ class Sdk {
|
|||
|
||||
var resolveManager = (defaultInstance: AcquisitionManager): void => {
|
||||
if (userDeploymentKey) {
|
||||
var customConfiguration: Configuration = { deploymentKey: userDeploymentKey, serverUrl: Sdk.DefaultConfiguration.serverUrl, ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion };
|
||||
var customConfiguration: Configuration = {
|
||||
deploymentKey: userDeploymentKey,
|
||||
serverUrl: Sdk.DefaultConfiguration.serverUrl,
|
||||
ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion,
|
||||
appVersion: Sdk.DefaultConfiguration.appVersion,
|
||||
clientUniqueId: Sdk.DefaultConfiguration.clientUniqueId
|
||||
};
|
||||
var customAcquisitionManager: AcquisitionManager = new AcquisitionManager(new HttpRequester(), customConfiguration);
|
||||
callback(null, customAcquisitionManager);
|
||||
} else {
|
||||
|
@ -34,13 +41,21 @@ class Sdk {
|
|||
} else {
|
||||
NativeAppInfo.getServerURL((serverError: Error, serverURL: string) => {
|
||||
NativeAppInfo.getDeploymentKey((depolymentKeyError: Error, deploymentKey: string) => {
|
||||
if (!serverURL || !deploymentKey) {
|
||||
callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
|
||||
} else {
|
||||
Sdk.DefaultConfiguration = { deploymentKey: deploymentKey, serverUrl: serverURL, ignoreAppVersion: false };
|
||||
Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
|
||||
resolveManager(Sdk.DefaultAcquisitionManager);
|
||||
}
|
||||
NativeAppInfo.getApplicationVersion((appVersionError: Error, appVersion: string) => {
|
||||
if (!serverURL || !deploymentKey || !appVersion) {
|
||||
callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
|
||||
} else {
|
||||
Sdk.DefaultConfiguration = {
|
||||
deploymentKey: deploymentKey,
|
||||
serverUrl: serverURL,
|
||||
ignoreAppVersion: false,
|
||||
appVersion: appVersion,
|
||||
clientUniqueId: device.uuid
|
||||
};
|
||||
Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
|
||||
resolveManager(Sdk.DefaultAcquisitionManager);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -49,14 +64,14 @@ class Sdk {
|
|||
/**
|
||||
* Reports the update status to the CodePush server.
|
||||
*/
|
||||
public static reportStatus(status: string, callback?: Callback<void>) {
|
||||
public static reportStatus(status: string, pkg: IPackage, callback?: Callback<void>) {
|
||||
try {
|
||||
Sdk.getAcquisitionManager((error: Error, acquisitionManager: AcquisitionManager) => {
|
||||
if (error) {
|
||||
callback && callback(error, null);
|
||||
}
|
||||
else {
|
||||
acquisitionManager.reportStatus(status, null, callback);
|
||||
acquisitionManager.reportStatusDeploy(pkg, status, callback);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче