Skip to content

Commit 0526f8f

Browse files
author
max-mironov
committed
Merge branch 'master' of https://github.com/Microsoft/code-push
2 parents 9d3f7f2 + 2f55f5f commit 0526f8f

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

cli/README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,14 @@ This specifies the relative path to where the assets, JS bundle and sourcemap fi
573573

574574
```shell
575575
code-push release-cordova <appName> <platform>
576+
[--build]
576577
[--deploymentName <deploymentName>]
577578
[--description <description>]
579+
[--isReleaseBuildType]
578580
[--mandatory]
579581
[--noDuplicateReleaseError]
580-
[--targetBinaryVersion <targetBinaryVersion>]
581582
[--rollout <rolloutPercentage>]
582-
[--build]
583+
[--targetBinaryVersion <targetBinaryVersion>]
583584
```
584585

585586
The `release-cordova` command is a Cordova-specific version of the "vanilla" [`release`](#releasing-app-updates) command, which supports all of the same parameters (e.g. `--mandatory`, `--description`), yet simplifies the process of releasing updates by performing the following additional behavior:
@@ -611,6 +612,12 @@ This is the same parameter as the one described in the [above section](#app-name
611612

612613
This specifies which platform the current update is targeting, and can be either `ios` or `android` (case-insensitive).
613614

615+
#### Build parameter
616+
617+
Specifies whether you want to run `cordova build` instead of `cordova prepare` (which is the default behavior), when generating your updated web assets. This is valuable if your project includes before and/or after build hooks (e.g. to transpile TypeScript), and therefore, having CodePush simply run `cordova prepare` isn't sufficient to create and release an update. If left unspecified, this defaults to `false`.
618+
619+
*NOTE: This parameter can be set using either --build or -b*
620+
614621
#### Deployment name parameter
615622

616623
This is the same parameter as the one described in the [above section](#deployment-name-parameter).
@@ -619,6 +626,14 @@ This is the same parameter as the one described in the [above section](#deployme
619626

620627
This is the same parameter as the one described in the [above section](#description-parameter).
621628

629+
#### Disabled parameter
630+
631+
This is the same parameter as the one described in the [above section](#disabled-parameter).
632+
633+
#### IsReleaseBuildType parameter
634+
635+
If `build` option is true specifies whether perform a release build. If left unspecified, this defaults to `debug`.
636+
622637
#### Mandatory parameter
623638

624639
This is the same parameter as the one described in the [above section](#mandatory-parameter).
@@ -635,16 +650,6 @@ This is the same parameter as the one described in the [above section](#rollout-
635650

636651
This is the same parameter as the one described in the [above section](#target-binary-version-parameter). If left unspecified, the command defaults to targeting only the specified version in the project's metadata (`Info.plist` if this update is for iOS clients, and `build.gradle` for Android clients).
637652

638-
#### Disabled parameter
639-
640-
This is the same parameter as the one described in the [above section](#disabled-parameter).
641-
642-
#### Build parameter
643-
644-
Specifies whether you want to run `cordova build` instead of `cordova prepare` (which is the default behavior), when generating your updated web assets. This is valuable if your project includes before and/or after build hooks (e.g. to transpile TypeScript), and therefore, having CodePush simply run `cordova prepare` isn't sufficient to create and release an update. If left unspecified, this defaults to `false`.
645-
646-
*NOTE: This parameter can be set using either --build or -b*
647-
648653
## Debugging CodePush Integration
649654

650655
Once you've released an update, and the Cordova or React Native plugin has been integrated into your app, it can be helpful to diagnose how the plugin is behaving, especially if you run into an issue and want to understand why. In order to debug the CodePush update discovery experience, you can run the following command in order to easily view the diagnostic logs produced by the CodePush plugin within your app:

cli/definitions/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export interface IReleaseCommand extends IReleaseBaseCommand {
187187
export interface IReleaseCordovaCommand extends IReleaseBaseCommand {
188188
build: boolean;
189189
platform: string;
190+
isReleaseBuildType?: boolean;
190191
}
191192

192193
export interface IReleaseReactCommand extends IReleaseBaseCommand {

cli/script/command-executor.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ export var confirm = (message: string = "Are you sure?"): Promise<boolean> => {
9494
resolve(true);
9595
} else {
9696
if (!rejected){
97-
console.log("Invalid response: \"" + result.response + "\"");
98-
}
97+
console.log("Invalid response: \"" + result.response + "\"");
98+
}
9999
resolve(false);
100100
}
101101
});
@@ -967,7 +967,7 @@ function getReactNativeProjectAppVersion(command: cli.IReleaseReactCommand, proj
967967
appVersion = parsedProperties[propertyName];
968968
if (appVersion) {
969969
break;
970-
}
970+
}
971971
} catch (e) {
972972
throw new Error(`Unable to parse "${propertiesFile}". Please ensure it is a well-formed properties file.`);
973973
}
@@ -1078,14 +1078,14 @@ function promote(command: cli.IPromoteCommand): Promise<void> {
10781078
appVersion: command.appStoreVersion,
10791079
description: command.description,
10801080
label: command.label,
1081-
isDisabled: getYargsBooleanOrNull(command.disabled),
1082-
isMandatory: getYargsBooleanOrNull(command.mandatory),
1081+
isDisabled: command.disabled,
1082+
isMandatory: command.mandatory,
10831083
rollout: command.rollout
10841084
};
10851085

10861086
return sdk.promote(command.appName, command.sourceDeploymentName, command.destDeploymentName, packageInfo)
10871087
.then((): void => {
1088-
log("Successfully promoted " + (command.label !== null ? "\"" + command.label + "\" of " : "") + "the \"" + command.sourceDeploymentName + "\" deployment of the \"" + command.appName + "\" app to the \"" + command.destDeploymentName + "\" deployment.");
1088+
log("Successfully promoted " + (command.label ? "\"" + command.label + "\" of " : "") + "the \"" + command.sourceDeploymentName + "\" deployment of the \"" + command.appName + "\" app to the \"" + command.destDeploymentName + "\" deployment.");
10891089
})
10901090
.catch((err: CodePushError) => releaseErrorHandler(err, command));
10911091
}
@@ -1094,8 +1094,8 @@ function patch(command: cli.IPatchCommand): Promise<void> {
10941094
var packageInfo: PackageInfo = {
10951095
appVersion: command.appStoreVersion,
10961096
description: command.description,
1097-
isMandatory: getYargsBooleanOrNull(command.mandatory),
1098-
isDisabled: getYargsBooleanOrNull(command.disabled),
1097+
isMandatory: command.mandatory,
1098+
isDisabled: command.disabled,
10991099
rollout: command.rollout
11001100
};
11011101

@@ -1112,15 +1112,15 @@ function patch(command: cli.IPatchCommand): Promise<void> {
11121112
}
11131113

11141114
export var release = (command: cli.IReleaseCommand): Promise<void> => {
1115-
1115+
11161116
if (isBinaryOrZip(command.package)) {
11171117
throw new Error("It is unnecessary to package releases in a .zip or binary file. Please specify the direct path to the update content's directory (e.g. /platforms/ios/www) or file (e.g. main.jsbundle).");
11181118
}
1119-
1119+
11201120
throwForInvalidSemverRange(command.appStoreVersion);
11211121
var filePath: string = command.package;
11221122
var isSingleFilePackage: boolean = true;
1123-
1123+
11241124
if (fs.lstatSync(filePath).isDirectory()) {
11251125
isSingleFilePackage = false;
11261126
}
@@ -1144,7 +1144,7 @@ export var release = (command: cli.IReleaseCommand): Promise<void> => {
11441144
isMandatory: command.mandatory,
11451145
rollout: command.rollout
11461146
};
1147-
1147+
11481148
return sdk.isAuthenticated(true)
11491149
.then((isAuth: boolean): Promise<void> => {
11501150
return sdk.release(command.appName, command.deploymentName, filePath, command.appStoreVersion, updateMetadata, uploadProgress);
@@ -1175,7 +1175,9 @@ export var releaseCordova = (command: cli.IReleaseCordovaCommand): Promise<void>
11751175
throw new Error("Platform must be either \"ios\" or \"android\".");
11761176
}
11771177

1178-
var cordovaCommand: string = command.build ? "build" : "prepare";
1178+
var cordovaCommand: string = command.build ?
1179+
(command.isReleaseBuildType ? "build --release" : "build") :
1180+
"prepare";
11791181
var cordovaCLI: string = "cordova";
11801182

11811183
// Check whether the Cordova or PhoneGap CLIs are
@@ -1460,11 +1462,6 @@ function isBinaryOrZip(path: string): boolean {
14601462
|| path.search(/\.ipa$/i) !== -1;
14611463
}
14621464

1463-
function getYargsBooleanOrNull(value: any): boolean {
1464-
// Yargs treats a boolean argument as an array of size 2 for null, third is the value of boolean.
1465-
return value && value.length > 2 ? value[2] : null;
1466-
}
1467-
14681465
function throwForInvalidEmail(email: string): void {
14691466
if (!emailValidator.validate(email)) {
14701467
throw new Error("\"" + email + "\" is an invalid e-mail address.");

cli/script/command-parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,14 @@ var argv = yargs.usage(USAGE_PREFIX + " <command>")
401401
.example("release-cordova MyApp ios", "Releases the Cordova iOS project in the current working directory to the \"MyApp\" app's \"Staging\" deployment")
402402
.example("release-cordova MyApp android -d Production", "Releases the Cordova Android project in the current working directory to the \"MyApp\" app's \"Production\" deployment")
403403
.option("build", { alias: "b", default: false, demand: false, description: "Invoke \"cordova build\" instead of \"cordova prepare\"", type: "boolean" })
404+
.option("isReleaseBuildType", { alias: "rb", default: false, demand: false, description: "If \"build\" option is true specifies whether perform a release build", type: "boolean" })
404405
.option("deploymentName", { alias: "d", default: "Staging", demand: false, description: "Deployment to release the update to", type: "string" })
405406
.option("description", { alias: "des", default: null, demand: false, description: "Description of the changes made to the app in this release", type: "string" })
406407
.option("disabled", { alias: "x", default: false, demand: false, description: "Specifies whether this release should be immediately downloadable", type: "boolean" })
407408
.option("mandatory", { alias: "m", default: false, demand: false, description: "Specifies whether this release should be considered mandatory", type: "boolean" })
408409
.option("noDuplicateReleaseError", { default: false, demand: false, description: "When this flag is set, releasing a package that is identical to the latest release will produce a warning instead of an error", type: "boolean" })
409410
.option("rollout", { alias: "r", default: "100%", demand: false, description: "Percentage of users this release should be immediately available to", type: "string" })
410-
.option("targetBinaryVersion", { alias: "t", default: null, demand: false, description: "Semver expression that specifies the binary app version(s) this release is targeting (e.g. 1.1.0, ~1.2.3). If omitted, the release will target the exact version specified in the config.xml file.", type: "string" })
411+
.option("targetBinaryVersion", { alias: "t", default: null, demand: false, description: "Semver expression that specifies the binary app version(s) this release is targeting (e.g. 1.1.0, ~1.2.3). If omitted, the release will target the exact version specified in the config.xml file.", type: "string" })
411412
.check((argv: any, aliases: { [aliases: string]: string }): any => { return checkValidReleaseOptions(argv); });
412413

413414
addCommonConfiguration(yargs);
@@ -806,6 +807,7 @@ function createCommand(): cli.ICommand {
806807
releaseCordovaCommand.noDuplicateReleaseError = argv["noDuplicateReleaseError"];
807808
releaseCordovaCommand.rollout = getRolloutValue(argv["rollout"]);
808809
releaseCordovaCommand.appStoreVersion = argv["targetBinaryVersion"];
810+
releaseCordovaCommand.isReleaseBuildType = argv["isReleaseBuildType"];
809811
}
810812
break;
811813

0 commit comments

Comments
 (0)