Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generates assetlinks.json when building the App #179

Merged
merged 3 commits into from
May 21, 2020

Conversation

andreban
Copy link
Member

  • Uses information from they keystore and the applicationId to
    generate the Digital Asset Links file that matches the key used
    to build the signed APK.

  • If the developer opted into Play Signing by Play the fingerprint
    won't match and the Digital Asset Links validation will not
    validate

Closes #5

- Uses information from they keystore and the applicationId to
  generate the Digital Asset Links file that matches the key used
  to build the signed APK.

- If the developer opted into Play Signing by Play the fingerprint
  won't match and the Digital Asset Links validation will not
  validate
@andreban andreban added the enhancement New feature or request label May 20, 2020
Copy link
Collaborator

@PEConn PEConn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - could do with some tests though :-)

import {AndroidSdkTools, Config, GradleWrapper, JdkHelper, Log, TwaManifest}
from '@bubblewrap/core';
import {AndroidSdkTools, Config, DigitalAssetLinks, GradleWrapper, JdkHelper, Log, TwaManifest,
KeyTool} from '@bubblewrap/core';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an ordering to these imports? If they're alphabetical, KeyTool is in the wrong place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code doesn't automatically sort it, do I've been doing this manually after auto-imports. Forgot about this one.

@@ -137,5 +139,31 @@ export async function build(
);

log.info(`Signed Android App generated at "${outputFile}"`);

try {
const digitalAssetLinksFile = './assetlinks.json';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to be relative to the directory the tool was run from? Is that what we want?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that, but for now I'm following what we're doing for ./app-release-signed.apk. I do think a flag to output somewhere different in the future will be useful (will be a larger change than this, as it'll touch other steps).

@@ -137,5 +139,31 @@ export async function build(
);

log.info(`Signed Android App generated at "${outputFile}"`);

try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say you probably want to move this into its own function, that way we can make the if on line 153 a guard clause and return early afterwards.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. I thought about it when writing the if statement but ended up forgetting. 🤦

await fs.promises.writeFile(digitalAssetLinksFile, digitalAssetLinks);

log.info(`Digital Asset Links file generated at ${digitalAssetLinksFile}`);
log.warn('If opting into "App Signing by Google Play" when uploading the Android app for ' +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you're doing this, but I don't like the idea of the tool outputting a warning that the user can't get rid of. I'm not sure there's a better way though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do info and just hightlight it with colors. How does that sound?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more that even if the user does everything right, they're going to have a big highlighted warning every time they run the tool.

I think longer term we should have something in twa-config for Play Signing - either a "isUsingPlaySigning: false" the user can set or a "playSigningSignatures: '...'" they can use to make things work right. It's probably outside of the scope for this change though.

}

const digitalAssetLinks =
DigitalAssetLinks.generateAssetLinks(twaManifest.packageId, sha256Fingerprint);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@andreban andreban merged commit 899245b into GoogleChromeLabs:master May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate /.well-know/assetlinks.json
2 participants