Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
fix(documentation): add extra information about the sha256Fingerprints
Browse files Browse the repository at this point in the history
  • Loading branch information
celinekurpershoek committed Jan 16, 2020
1 parent 75824f7 commit cc62119
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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

Expand Down
18 changes: 10 additions & 8 deletions test/example/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
}
}
]
}
32 changes: 16 additions & 16 deletions test/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})

Expand Down Expand Up @@ -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',
Expand All @@ -103,7 +103,7 @@ describe('Test TWA module', () => {
beforeAll(() => {
prepareAppFolder(appDirectory)
})


test('Get error when gradle file is undefined', async () => {
expect.assertions(1)
Expand Down Expand Up @@ -156,19 +156,19 @@ describe('Test TWA module', () => {
}
})
})

describe('Test generate-asset-links-file', () => {
const options = {
applicationId: "test",
sha256Fingerprints: "123"
sha256Fingerprints: ["123"]
}

const mockdata = [{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "test",
"sha256_cert_fingerprints": "123"
"sha256_cert_fingerprints": ["123"]
},
}]

Expand All @@ -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/)
}
})

Expand All @@ -209,5 +209,5 @@ describe('Test TWA module', () => {
})
})
})


0 comments on commit cc62119

Please sign in to comment.