Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 89cbef2

Browse files
author
max-mironov
authored
Add build type option to release cordova command (#409)
* Improved messages to make intention of creating different apps for different platforms more clear Due to multiple requests in discord chanel, microsoft/react-native-code-push#723, microsoft/react-native-code-push#717 * Add ability to specify build type for Cordova Also fixes issue #392 * revert changes not related to this PR * Minor tweak for readme * Reordered param names for cordova-release command in Readme alphabetically
1 parent e3b78ee commit 89cbef2

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

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)