From cc621199b3b8f6424b009e347bba16b9b790dca8 Mon Sep 17 00:00:00 2001 From: Celine Kurpershoek Date: Thu, 16 Jan 2020 13:40:09 +0100 Subject: [PATCH] fix(documentation): add extra information about the sha256Fingerprints --- README.md | 6 ++++-- test/example/nuxt.config.js | 18 ++++++++++-------- test/module.test.js | 32 ++++++++++++++++---------------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 8811864..6af44d0 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Add `nuxt-twa-module` to `modules` section of `nuxt.config.js`. /* module options */ defaultUrl: 'https://your-url.com', hostName: 'your-url.com', - sha256Fingerprints: [/* your SHA-256 keys */], + sha256Fingerprints: ['/* your SHA-256 keys */'], applicationId: 'com.example.example', launcherName: 'Your app name', versionCode: 1, @@ -58,6 +58,8 @@ Add `nuxt-twa-module` to `modules` section of `nuxt.config.js`. } ``` +the `sha256Fingerprints` by is an array with one SHA-256 key string. But if you have multiple you can add them to the array. More information about the website asociation: https://developer.android.com/training/app-links/verify-site-associations#web-assoc + ## Time to build 🏗 When the configuration is done you can run your project like you are used to. @@ -75,7 +77,7 @@ npm run generate ### Output - An `android` folder in your project root, which you can open in Android Studio to [build your app](https://developer.android.com/studio/run/). When you've build and tested your app you can use [Generate Signed Bundle/APK](https://developer.android.com/studio/publish/app-signing). This will generate a .aab file that can be uploaded to the Google Play Store. -- You Nuxt app with an added `.well-known` folder which is needed to make your domain trusted with the app in the store. +- Your Nuxt app with an added `.well-known` folder which is needed to make your domain trusted with the app in the store. ## Debug diff --git a/test/example/nuxt.config.js b/test/example/nuxt.config.js index 9e95a64..2ae2137 100644 --- a/test/example/nuxt.config.js +++ b/test/example/nuxt.config.js @@ -8,13 +8,15 @@ module.exports = { resourceHints: false }, modules: [ - { handler: require('../../'), options: { - hostName: 'test.com', - defaultUrl: 'https://test.com', - sha256Fingerprints: '123', - iconPath: '/test/fixture/static/icon.png', - distFolder: '/test/example/.nuxt/dist/client', - androidFolder: './test/example/android/' - } } + { + handler: require('../../'), options: { + hostName: 'test.com', + defaultUrl: 'https://test.com', + sha256Fingerprints: ['123'], + iconPath: '/test/fixture/static/icon.png', + distFolder: '/test/example/.nuxt/dist/client', + androidFolder: './test/example/android/' + } + } ] } \ No newline at end of file diff --git a/test/module.test.js b/test/module.test.js index 4213d18..1eeba99 100644 --- a/test/module.test.js +++ b/test/module.test.js @@ -10,32 +10,32 @@ const { generateAssetLinksFile, generateConfig } = require('../lib/generate-asse describe('Test TWA module', () => { const iconPath = path.resolve(__dirname, 'fixture/static/icon.png') - const testFolder = path.resolve(__dirname, 'test-env') + const testFolder = path.resolve(__dirname, 'test-env') beforeAll(() => { // Redirect std and console to consola too // Calling this once is sufficient consola.wrapAll() - if(fs.existsSync(testFolder)){ + if (fs.existsSync(testFolder)) { rimraf(testFolder, (error) => console.log(error)) } fs.mkdirSync(testFolder, { recursive: true }) }) - beforeEach(() => { + beforeEach(() => { // Re-mock consola before each test call to remove // calls from before - consola.mockTypes(() => jest.fn()) + consola.mockTypes(() => jest.fn()) }) - afterAll( () => { + afterAll(() => { return rimraf(testFolder, (error) => console.log(error)) }) describe('Test generate-icons', () => { - const destination = path.resolve(testFolder, 'res/') + const destination = path.resolve(testFolder, 'res/') - beforeAll( () => { + beforeAll(() => { fs.mkdirSync(destination, { recursive: true }) }) @@ -82,7 +82,7 @@ describe('Test TWA module', () => { }) describe('Test generate-build-file', () => { - const appDirectory = path.resolve(__dirname, 'test-env/app') + const appDirectory = path.resolve(__dirname, 'test-env/app') const gradleFile = path.resolve(__dirname, 'test-env/app/build.gradle') const buildOptions = { defaultUrl: 'test', @@ -103,7 +103,7 @@ describe('Test TWA module', () => { beforeAll(() => { prepareAppFolder(appDirectory) }) - + test('Get error when gradle file is undefined', async () => { expect.assertions(1) @@ -156,11 +156,11 @@ describe('Test TWA module', () => { } }) }) - + describe('Test generate-asset-links-file', () => { const options = { applicationId: "test", - sha256Fingerprints: "123" + sha256Fingerprints: ["123"] } const mockdata = [{ @@ -168,7 +168,7 @@ describe('Test TWA module', () => { "target": { "namespace": "android_app", "package_name": "test", - "sha256_cert_fingerprints": "123" + "sha256_cert_fingerprints": ["123"] }, }] @@ -178,17 +178,17 @@ describe('Test TWA module', () => { await generateAssetLinksFile({}, '') } catch (error) { expect(error) - .toMatch(/Missing SHA256/) + .toMatch(/Missing SHA256/) } }) - test('Get error when destination path is invalid', async() => { + test('Get error when destination path is invalid', async () => { expect.assertions(1) try { await generateAssetLinksFile(options, '') } catch (error) { expect(error) - .toMatch(/No destination path/) + .toMatch(/No destination path/) } }) @@ -209,5 +209,5 @@ describe('Test TWA module', () => { }) }) }) - +