@revopush/code-push-cli 0.0.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/.eslintrc.json +17 -0
- package/.idea/cli.iml +9 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +774 -0
- package/bin/script/acquisition-sdk.js +178 -0
- package/bin/script/cli.js +23 -0
- package/bin/script/command-executor.js +1290 -0
- package/bin/script/command-parser.js +1097 -0
- package/bin/script/commands/debug.js +125 -0
- package/bin/script/hash-utils.js +203 -0
- package/bin/script/index.js +5 -0
- package/bin/script/management-sdk.js +419 -0
- package/bin/script/react-native-utils.js +249 -0
- package/bin/script/sign.js +69 -0
- package/bin/script/types/cli.js +40 -0
- package/bin/script/types/rest-definitions.js +19 -0
- package/bin/script/types.js +4 -0
- package/bin/script/utils/file-utils.js +50 -0
- package/bin/test/acquisition-rest-mock.js +108 -0
- package/bin/test/acquisition-sdk.js +188 -0
- package/bin/test/cli.js +1342 -0
- package/bin/test/hash-utils.js +149 -0
- package/bin/test/management-sdk.js +338 -0
- package/package.json +68 -0
- package/prettier.config.js +7 -0
- package/script/acquisition-sdk.ts +273 -0
- package/script/cli.ts +27 -0
- package/script/command-executor.ts +1610 -0
- package/script/command-parser.ts +1310 -0
- package/script/commands/debug.ts +148 -0
- package/script/hash-utils.ts +241 -0
- package/script/index.ts +5 -0
- package/script/management-sdk.ts +575 -0
- package/script/react-native-utils.ts +283 -0
- package/script/sign.ts +80 -0
- package/script/types/cli.ts +232 -0
- package/script/types/rest-definitions.ts +152 -0
- package/script/types.ts +35 -0
- package/script/utils/file-utils.ts +46 -0
- package/test/acquisition-rest-mock.ts +125 -0
- package/test/acquisition-sdk.ts +272 -0
- package/test/cli.ts +1692 -0
- package/test/hash-utils.ts +170 -0
- package/test/management-sdk.ts +438 -0
- package/test/resources/TestApp/android/app/build.gradle +56 -0
- package/test/resources/TestApp/iOS/TestApp/Info.plist +49 -0
- package/test/resources/TestApp/index.android.js +2 -0
- package/test/resources/TestApp/index.ios.js +2 -0
- package/test/resources/TestApp/index.windows.js +2 -0
- package/test/resources/TestApp/package.json +6 -0
- package/test/resources/TestApp/windows/TestApp/Package.appxmanifest +46 -0
- package/test/resources/ignoredMetadata.zip +0 -0
- package/test/resources/test.zip +0 -0
- package/test/superagent-mock-config.js +58 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.AcquisitionManager = exports.AcquisitionStatus = void 0;
|
|
6
|
+
class AcquisitionStatus {
|
|
7
|
+
static DeploymentSucceeded = "DeploymentSucceeded";
|
|
8
|
+
static DeploymentFailed = "DeploymentFailed";
|
|
9
|
+
}
|
|
10
|
+
exports.AcquisitionStatus = AcquisitionStatus;
|
|
11
|
+
class AcquisitionManager {
|
|
12
|
+
_appVersion;
|
|
13
|
+
_clientUniqueId;
|
|
14
|
+
_deploymentKey;
|
|
15
|
+
_httpRequester;
|
|
16
|
+
_ignoreAppVersion;
|
|
17
|
+
_serverUrl;
|
|
18
|
+
constructor(httpRequester, configuration) {
|
|
19
|
+
this._httpRequester = httpRequester;
|
|
20
|
+
this._serverUrl = configuration.serverUrl;
|
|
21
|
+
if (this._serverUrl.slice(-1) !== "/") {
|
|
22
|
+
this._serverUrl += "/";
|
|
23
|
+
}
|
|
24
|
+
this._appVersion = configuration.appVersion;
|
|
25
|
+
this._clientUniqueId = configuration.clientUniqueId;
|
|
26
|
+
this._deploymentKey = configuration.deploymentKey;
|
|
27
|
+
this._ignoreAppVersion = configuration.ignoreAppVersion;
|
|
28
|
+
}
|
|
29
|
+
queryUpdateWithCurrentPackage(currentPackage, callback) {
|
|
30
|
+
if (!currentPackage || !currentPackage.appVersion) {
|
|
31
|
+
throw new Error("Calling common acquisition SDK with incorrect package"); // Unexpected; indicates error in our implementation
|
|
32
|
+
}
|
|
33
|
+
const updateRequest = {
|
|
34
|
+
deploymentKey: this._deploymentKey,
|
|
35
|
+
appVersion: currentPackage.appVersion,
|
|
36
|
+
packageHash: currentPackage.packageHash,
|
|
37
|
+
isCompanion: this._ignoreAppVersion,
|
|
38
|
+
label: currentPackage.label,
|
|
39
|
+
clientUniqueId: this._clientUniqueId,
|
|
40
|
+
};
|
|
41
|
+
const requestUrl = this._serverUrl + "updateCheck?" + queryStringify(updateRequest);
|
|
42
|
+
this._httpRequester.request(0 /* Http.Verb.GET */, requestUrl, (error, response) => {
|
|
43
|
+
if (error) {
|
|
44
|
+
callback(error, /*remotePackage=*/ null);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (response.statusCode !== 200) {
|
|
48
|
+
callback(new Error(response.statusCode + ": " + response.body), /*remotePackage=*/ null);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let updateInfo;
|
|
52
|
+
try {
|
|
53
|
+
const responseObject = JSON.parse(response.body);
|
|
54
|
+
updateInfo = responseObject.updateInfo;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
callback(error, /*remotePackage=*/ null);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!updateInfo) {
|
|
61
|
+
callback(error, /*remotePackage=*/ null);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
else if (updateInfo.updateAppVersion) {
|
|
65
|
+
callback(/*error=*/ null, {
|
|
66
|
+
updateAppVersion: true,
|
|
67
|
+
appVersion: updateInfo.appVersion,
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
else if (!updateInfo.isAvailable) {
|
|
72
|
+
callback(/*error=*/ null, /*remotePackage=*/ null);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const remotePackage = {
|
|
76
|
+
deploymentKey: this._deploymentKey,
|
|
77
|
+
description: updateInfo.description,
|
|
78
|
+
label: updateInfo.label,
|
|
79
|
+
appVersion: updateInfo.appVersion,
|
|
80
|
+
isMandatory: updateInfo.isMandatory,
|
|
81
|
+
packageHash: updateInfo.packageHash,
|
|
82
|
+
packageSize: updateInfo.packageSize,
|
|
83
|
+
downloadUrl: updateInfo.downloadURL,
|
|
84
|
+
};
|
|
85
|
+
callback(/*error=*/ null, remotePackage);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
reportStatusDeploy(deployedPackage, status, previousLabelOrAppVersion, previousDeploymentKey, callback) {
|
|
89
|
+
const url = this._serverUrl + "reportStatus/deploy";
|
|
90
|
+
const body = {
|
|
91
|
+
appVersion: this._appVersion,
|
|
92
|
+
deploymentKey: this._deploymentKey,
|
|
93
|
+
};
|
|
94
|
+
if (this._clientUniqueId) {
|
|
95
|
+
body.clientUniqueId = this._clientUniqueId;
|
|
96
|
+
}
|
|
97
|
+
if (deployedPackage) {
|
|
98
|
+
body.label = deployedPackage.label;
|
|
99
|
+
body.appVersion = deployedPackage.appVersion;
|
|
100
|
+
switch (status) {
|
|
101
|
+
case AcquisitionStatus.DeploymentSucceeded:
|
|
102
|
+
case AcquisitionStatus.DeploymentFailed:
|
|
103
|
+
body.status = status;
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
if (callback) {
|
|
107
|
+
if (!status) {
|
|
108
|
+
callback(new Error("Missing status argument."), /*not used*/ null);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
callback(new Error('Unrecognized status "' + status + '".'), /*not used*/ null);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (previousLabelOrAppVersion) {
|
|
118
|
+
body.previousLabelOrAppVersion = previousLabelOrAppVersion;
|
|
119
|
+
}
|
|
120
|
+
if (previousDeploymentKey) {
|
|
121
|
+
body.previousDeploymentKey = previousDeploymentKey;
|
|
122
|
+
}
|
|
123
|
+
callback = typeof arguments[arguments.length - 1] === "function" && arguments[arguments.length - 1];
|
|
124
|
+
this._httpRequester.request(2 /* Http.Verb.POST */, url, JSON.stringify(body), (error, response) => {
|
|
125
|
+
if (callback) {
|
|
126
|
+
if (error) {
|
|
127
|
+
callback(error, /*not used*/ null);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (response.statusCode !== 200) {
|
|
131
|
+
callback(new Error(response.statusCode + ": " + response.body), /*not used*/ null);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
callback(/*error*/ null, /*not used*/ null);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
reportStatusDownload(downloadedPackage, callback) {
|
|
139
|
+
const url = this._serverUrl + "reportStatus/download";
|
|
140
|
+
const body = {
|
|
141
|
+
clientUniqueId: this._clientUniqueId,
|
|
142
|
+
deploymentKey: this._deploymentKey,
|
|
143
|
+
label: downloadedPackage.label,
|
|
144
|
+
};
|
|
145
|
+
this._httpRequester.request(2 /* Http.Verb.POST */, url, JSON.stringify(body), (error, response) => {
|
|
146
|
+
if (callback) {
|
|
147
|
+
if (error) {
|
|
148
|
+
callback(error, /*not used*/ null);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (response.statusCode !== 200) {
|
|
152
|
+
callback(new Error(response.statusCode + ": " + response.body), /*not used*/ null);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
callback(/*error*/ null, /*not used*/ null);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.AcquisitionManager = AcquisitionManager;
|
|
161
|
+
function queryStringify(object) {
|
|
162
|
+
let queryString = "";
|
|
163
|
+
let isFirst = true;
|
|
164
|
+
for (const property in object) {
|
|
165
|
+
if (object.hasOwnProperty(property)) {
|
|
166
|
+
const value = object[property];
|
|
167
|
+
if (!isFirst) {
|
|
168
|
+
queryString += "&";
|
|
169
|
+
}
|
|
170
|
+
queryString += encodeURIComponent(property) + "=";
|
|
171
|
+
if (value !== null && typeof value !== "undefined") {
|
|
172
|
+
queryString += encodeURIComponent(value);
|
|
173
|
+
}
|
|
174
|
+
isFirst = false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return queryString;
|
|
178
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// Copyright (c) Microsoft Corporation.
|
|
4
|
+
// Licensed under the MIT License.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const parser = require("./command-parser");
|
|
7
|
+
const execute = require("./command-executor");
|
|
8
|
+
const chalk = require("chalk");
|
|
9
|
+
function run() {
|
|
10
|
+
const command = parser.createCommand();
|
|
11
|
+
if (!command) {
|
|
12
|
+
parser.showHelp(/*showRootDescription*/ false);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
execute
|
|
16
|
+
.execute(command)
|
|
17
|
+
.catch((error) => {
|
|
18
|
+
console.error(chalk.red(`[Error] ${error.message}`));
|
|
19
|
+
process.exit(1);
|
|
20
|
+
})
|
|
21
|
+
.done();
|
|
22
|
+
}
|
|
23
|
+
run();
|