Skip to content

Commit

Permalink
Add build type option to release cordova command (#409)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
max-mironov committed Mar 10, 2017
1 parent e3b78ee commit 89cbef2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
29 changes: 17 additions & 12 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,14 @@ This specifies the relative path to where the assets, JS bundle and sourcemap fi

```shell
code-push release-cordova <appName> <platform>
[--build]
[--deploymentName <deploymentName>]
[--description <description>]
[--isReleaseBuildType]
[--mandatory]
[--noDuplicateReleaseError]
[--targetBinaryVersion <targetBinaryVersion>]
[--rollout <rolloutPercentage>]
[--build]
[--targetBinaryVersion <targetBinaryVersion>]
```

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:
Expand Down Expand Up @@ -611,6 +612,12 @@ This is the same parameter as the one described in the [above section](#app-name

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

#### Build parameter

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`.

*NOTE: This parameter can be set using either --build or -b*

#### Deployment name parameter

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

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

#### Disabled parameter

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

#### IsReleaseBuildType parameter

If `build` option is true specifies whether perform a release build. If left unspecified, this defaults to `debug`.

#### Mandatory parameter

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

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).

#### Disabled parameter

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

#### Build parameter

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`.

*NOTE: This parameter can be set using either --build or -b*

## Debugging CodePush Integration

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:
Expand Down
1 change: 1 addition & 0 deletions cli/definitions/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export interface IReleaseCommand extends IReleaseBaseCommand {
export interface IReleaseCordovaCommand extends IReleaseBaseCommand {
build: boolean;
platform: string;
isReleaseBuildType?: boolean;
}

export interface IReleaseReactCommand extends IReleaseBaseCommand {
Expand Down
4 changes: 3 additions & 1 deletion cli/script/command-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,9 @@ export var releaseCordova = (command: cli.IReleaseCordovaCommand): Promise<void>
throw new Error("Platform must be either \"ios\" or \"android\".");
}

var cordovaCommand: string = command.build ? "build" : "prepare";
var cordovaCommand: string = command.build ?
(command.isReleaseBuildType ? "build --release" : "build") :
"prepare";
var cordovaCLI: string = "cordova";

// Check whether the Cordova or PhoneGap CLIs are
Expand Down
4 changes: 3 additions & 1 deletion cli/script/command-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,14 @@ var argv = yargs.usage(USAGE_PREFIX + " <command>")
.example("release-cordova MyApp ios", "Releases the Cordova iOS project in the current working directory to the \"MyApp\" app's \"Staging\" deployment")
.example("release-cordova MyApp android -d Production", "Releases the Cordova Android project in the current working directory to the \"MyApp\" app's \"Production\" deployment")
.option("build", { alias: "b", default: false, demand: false, description: "Invoke \"cordova build\" instead of \"cordova prepare\"", type: "boolean" })
.option("isReleaseBuildType", { alias: "rb", default: false, demand: false, description: "If \"build\" option is true specifies whether perform a release build", type: "boolean" })
.option("deploymentName", { alias: "d", default: "Staging", demand: false, description: "Deployment to release the update to", type: "string" })
.option("description", { alias: "des", default: null, demand: false, description: "Description of the changes made to the app in this release", type: "string" })
.option("disabled", { alias: "x", default: false, demand: false, description: "Specifies whether this release should be immediately downloadable", type: "boolean" })
.option("mandatory", { alias: "m", default: false, demand: false, description: "Specifies whether this release should be considered mandatory", type: "boolean" })
.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" })
.option("rollout", { alias: "r", default: "100%", demand: false, description: "Percentage of users this release should be immediately available to", type: "string" })
.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" })
.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" })
.check((argv: any, aliases: { [aliases: string]: string }): any => { return checkValidReleaseOptions(argv); });

addCommonConfiguration(yargs);
Expand Down Expand Up @@ -806,6 +807,7 @@ function createCommand(): cli.ICommand {
releaseCordovaCommand.noDuplicateReleaseError = argv["noDuplicateReleaseError"];
releaseCordovaCommand.rollout = getRolloutValue(argv["rollout"]);
releaseCordovaCommand.appStoreVersion = argv["targetBinaryVersion"];
releaseCordovaCommand.isReleaseBuildType = argv["isReleaseBuildType"];
}
break;

Expand Down

0 comments on commit 89cbef2

Please sign in to comment.