From 2322e50e7e901a3a58e1916dbf5030ac0f72e048 Mon Sep 17 00:00:00 2001 From: Justine De Caires Date: Wed, 24 Feb 2021 20:37:25 -0800 Subject: [PATCH] Add --skipSigning option to build command --- packages/cli/README.md | 3 ++- packages/cli/src/lib/cmds/build.ts | 25 +++++++++++++++++++------ packages/cli/src/lib/cmds/help.ts | 1 + packages/cli/src/lib/strings.ts | 4 ++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 7ed14c9a..cc51fe9c 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -113,11 +113,12 @@ Set `BUBBLEWRAP_KEYSTORE_PASSWORD` for the key store password and `BUBBLEWRAP_KE Usage: ``` -bubblewrap build [--skipPwaValidation] +bubblewrap build [--skipPwaValidation] [--skipSigning] ``` Options: - `--skipPwaValidation`: skips validating the wrapped PWA against the Quality Criteria. + - `--skipSigning`: skips signing the built APK and App Bundle. ## `update` diff --git a/packages/cli/src/lib/cmds/build.ts b/packages/cli/src/lib/cmds/build.ts index dd93b946..430509d2 100644 --- a/packages/cli/src/lib/cmds/build.ts +++ b/packages/cli/src/lib/cmds/build.ts @@ -171,19 +171,32 @@ class Build { } const twaManifest = await TwaManifest.fromFile(TWA_MANIFEST_FILE_NAME); - 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; diff --git a/packages/cli/src/lib/cmds/help.ts b/packages/cli/src/lib/cmds/help.ts index eef20507..c43a79a3 100644 --- a/packages/cli/src/lib/cmds/help.ts +++ b/packages/cli/src/lib/cmds/help.ts @@ -60,6 +60,7 @@ const HELP_MESSAGES = new Map( '', 'Options:', '--skipPwaValidation ....... skips validating the wrapped PWA against the Quality Criteria', + '--skipSigning ............. skips signing the built APK and App Bundle', ].join('\n')], ['update', [ 'Usage:', diff --git a/packages/cli/src/lib/strings.ts b/packages/cli/src/lib/strings.ts index fe3341b1..d9708e8b 100644 --- a/packages/cli/src/lib/strings.ts +++ b/packages/cli/src/lib/strings.ts @@ -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; @@ -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 => {