Skip to content

Commit

Permalink
Add --skipSigning option to build command (#473)
Browse files Browse the repository at this point in the history
Co-authored-by: André Cipriani Bandarra <andreban@google.com>
  • Loading branch information
Justine De Caires and andreban authored Feb 25, 2021
1 parent 2eee55a commit 1b278d3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ Set `BUBBLEWRAP_KEYSTORE_PASSWORD` for the key store password and `BUBBLEWRAP_KE
Usage:

```
bubblewrap build [--skipPwaValidation] [--manifest="<path-twa-manifest>"]
bubblewrap build [--skipPwaValidation] [--skipSigning] [--manifest="<path-twa-manifest>"]
```

Options:
- `--skipPwaValidation`: skips validating the wrapped PWA against the Quality Criteria.
- `--skipSigning`: skips signing the built APK and App Bundle.
- `--manifest`: directory where the client should look for `twa-manifest.json`.


Expand Down
29 changes: 23 additions & 6 deletions packages/cli/src/lib/cmds/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,36 @@ class Build {

const manifestFile = this.args.manifest || path.join(process.cwd(), TWA_MANIFEST_FILE_NAME);
const twaManifest = await TwaManifest.fromFile(manifestFile);
const passwords = await this.getPasswords(twaManifest.signingKey);

let passwords = null;
if (!this.args.skipSigning) {
passwords = await this.getPasswords(twaManifest.signingKey);
}

// Builds the Android Studio Project
this.prompt.printMessage(messages.messageBuildingApp);

await this.buildApk();
await this.signApk(twaManifest.signingKey, passwords);
this.prompt.printMessage(messages.messageApkSucess(APK_SIGNED_FILE_NAME));
if (passwords) {
await this.signApk(twaManifest.signingKey, passwords);
}
const apkFileName = this.args.skipSigning ?
APK_ALIGNED_FILE_NAME :
APK_SIGNED_FILE_NAME;
this.prompt.printMessage(messages.messageApkSuccess(apkFileName));

await this.buildAppBundle();
await this.signAppBundle(twaManifest.signingKey, passwords);
this.prompt.printMessage(messages.messageAppBundleSuccess(APP_BUNDLE_SIGNED_FILE_NAME));
if (passwords) {
await this.signAppBundle(twaManifest.signingKey, passwords);
}
const appBundleFileName = this.args.skipSigning ?
APP_BUNDLE_BUILD_OUTPUT_FILE_NAME :
APP_BUNDLE_SIGNED_FILE_NAME;
this.prompt.printMessage(messages.messageAppBundleSuccess(appBundleFileName));

await this.generateAssetLinks(twaManifest, passwords);
if (passwords) {
await this.generateAssetLinks(twaManifest, passwords);
}

if (validationPromise !== null) {
const result = await validationPromise;
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/lib/cmds/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const HELP_MESSAGES = new Map<string, string>(
'',
'Options:',
'--skipPwaValidation ....... skips validating the wrapped PWA against the Quality Criteria',
'--skipSigning ............. skips signing the built APK and App Bundle',
'--manifest ................ directory where the client should look for twa-manifest.json',
].join('\n')],
['update', [
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Messages = {
messageInitializingWebManifest: (manifestUrl: string) => string;
messageAndroidAppDetails: string;
messageAndroidAppDetailsDesc: string;
messageApkSucess: (filename: string) => string;
messageApkSuccess: (filename: string) => string;
messageAppBundleSuccess: (filename: string) => string;
messageBuildingApp: string;
messageDigitalAssetLinksSuccess: (filename: string) => string;
Expand Down Expand Up @@ -165,7 +165,7 @@ into a device:
\t- ${bold('Status bar color:')} sets the status bar color used when the
\t application is in foreground. Example: ${cyan('#7CC0FF')}\n`,
messageApkSucess: (filename: string): string => {
messageApkSuccess: (filename: string): string => {
return `\t- Generated Android APK at ${cyan(filename)}`;
},
messageAppBundleSuccess: (filename: string): string => {
Expand Down

0 comments on commit 1b278d3

Please sign in to comment.