From b9605db7c33ae15bf14b6933468ff15c7d5564dc Mon Sep 17 00:00:00 2001 From: Denes Sapi Date: Thu, 7 Mar 2024 17:25:12 +0100 Subject: [PATCH 1/4] fix: Make gradlew executable --- android/gradlew | 0 example/android/gradlew | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 android/gradlew mode change 100644 => 100755 example/android/gradlew diff --git a/android/gradlew b/android/gradlew old mode 100644 new mode 100755 diff --git a/example/android/gradlew b/example/android/gradlew old mode 100644 new mode 100755 From 40aa107cdaa031ed313f1b0cd9bce57e3ad5c80d Mon Sep 17 00:00:00 2001 From: Denes Sapi Date: Thu, 7 Mar 2024 17:25:49 +0100 Subject: [PATCH 2/4] fix: Ignore the example folder during formatting check --- .eslintignore | 1 + .prettierignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.eslintignore b/.eslintignore index 9d0b71a..18b63ae 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ build dist +example \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 9d0b71a..18b63ae 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ build dist +example \ No newline at end of file From 8c88c1a5c20b716ca2e65c0678144b2d54df90bc Mon Sep 17 00:00:00 2001 From: Denes Sapi Date: Thu, 7 Mar 2024 17:26:18 +0100 Subject: [PATCH 3/4] fix: Fix code format with Prettier --- src/config.ts | 11 +++++------ src/definitions.ts | 9 +++++---- src/index.ts | 2 +- src/web.ts | 20 +++++++++++++------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/config.ts b/src/config.ts index d67c61f..545931c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -4,9 +4,9 @@ import type { TrapConfigurationType } from './definitions'; import { CollectorTypes } from './definitions'; const reporterConfig = { - apiKeyName: "graboxy-api-key", + apiKeyName: 'graboxy-api-key', - apiKeyValue: "api-key-value", + apiKeyValue: 'api-key-value', cachedTransport: true, @@ -18,7 +18,7 @@ const reporterConfig = { maxFileCacheSize: 5_000_000, - url: "https://trap.graboxy.com/api/1/submit/{sessionId}/{streamId}", + url: 'https://trap.graboxy.com/api/1/submit/{sessionId}/{streamId}', readTimeout: 500, @@ -105,11 +105,10 @@ const reducedCollector = { metadataSubmissionInterval: 60_000, - useGestureRecognizer: true + useGestureRecognizer: true, }; -export class TrapConfig implements TrapConfigurationType -{ +export class TrapConfig implements TrapConfigurationType { defaultDataCollection = defaultCollector; lowBatteryDataCollection = reducedCollector; diff --git a/src/definitions.ts b/src/definitions.ts index 171442d..b6d55c6 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -7,14 +7,15 @@ export interface CapacitorTrapPlugin { /** * Add custom metadata */ - addCustomMetadata(options: { key: string, value: any }): Promise; + addCustomMetadata(options: { key: string; value: any }): Promise; /** * Checks permission for the specific collector. Returns true if the collector * has the required permission. */ - checkPermission(options: { collector: CollectorTypes }) - : Promise; + checkPermission(options: { + collector: CollectorTypes; + }): Promise; /** * Initialize the plugin @@ -34,7 +35,7 @@ export interface CapacitorTrapPlugin { /** * Request permission for the specific collector. */ - requestPermission(options: { collector: CollectorTypes }) : Promise; + requestPermission(options: { collector: CollectorTypes }): Promise; /** * Start data collection diff --git a/src/index.ts b/src/index.ts index e68a73d..45a599a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,4 +8,4 @@ const CapacitorTrap = registerPlugin('CapacitorTrap', { export * from './definitions'; export { TrapConfig } from './config'; -export { CapacitorTrap }; \ No newline at end of file +export { CapacitorTrap }; diff --git a/src/web.ts b/src/web.ts index 56ddeb5..762f70e 100644 --- a/src/web.ts +++ b/src/web.ts @@ -1,6 +1,11 @@ import { WebPlugin } from '@capacitor/core'; -import type { CapacitorTrapPlugin, CollectorTypes, PermissionResult, TrapConfigurationType } from './definitions'; +import type { + CapacitorTrapPlugin, + CollectorTypes, + PermissionResult, + TrapConfigurationType, +} from './definitions'; export class CapacitorTrapWeb extends WebPlugin implements CapacitorTrapPlugin { // eslint-disable-next-line @@ -9,13 +14,14 @@ export class CapacitorTrapWeb extends WebPlugin implements CapacitorTrapPlugin { } // eslint-disable-next-line - addCustomMetadata(options : {key: string, value: any }): Promise { + addCustomMetadata(options: { key: string; value: any }): Promise { throw new Error('Method not implemented.'); } // eslint-disable-next-line - checkPermission(options: { collector: CollectorTypes; }) - : Promise { + checkPermission(options: { + collector: CollectorTypes; + }): Promise { throw new Error('Method not implemented.'); } @@ -24,17 +30,17 @@ export class CapacitorTrapWeb extends WebPlugin implements CapacitorTrapPlugin { } // eslint-disable-next-line - configure(options: { config: TrapConfigurationType } ): Promise { + configure(options: { config: TrapConfigurationType }): Promise { throw new Error('Method not implemented.'); } // eslint-disable-next-line - removeCustomMetadata(options : { key: string }): Promise { + removeCustomMetadata(options: { key: string }): Promise { throw new Error('Method not implemented.'); } // eslint-disable-next-line - requestPermission(options: { collector: CollectorTypes; }) : Promise { + requestPermission(options: { collector: CollectorTypes }): Promise { throw new Error('Method not implemented.'); } From 0a1002790fa5cbd4fc3bafd73bae3d30745dccef Mon Sep 17 00:00:00 2001 From: Denes Sapi Date: Tue, 5 Mar 2024 13:50:32 +0100 Subject: [PATCH 4/4] chore: Add GitHub workflows --- .github/workflows/release.yaml | 29 ++++++++++++++++++ .github/workflows/test.yaml | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4f13930 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +name: Publish Package to npmjs + +permissions: + contents: write + id-token: write + +on: + push: + tags: + - '?.?.?' + +env: + NODE_VERSION: 18 + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - run: npm publish --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..da96839 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,54 @@ +name: test +permissions: + contents: read +on: + push: + branches: [main] + pull_request: +# Spend CI time only on latest ref +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + NODE_VERSION: 18 + JAVA_VERSION: 17 + +jobs: + verify: + name: Verify + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Set up Java ${{ env.JAVA_VERSION }} + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: ${{ env.JAVA_VERSION }} + - name: Install dependencies + run: npm ci + - name: Build iOS + run: npm run verify:ios + - name: Build Android + run: npm run verify:android + - name: Build Web + run: npm run verify:web + lint: + name: Lint + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Install dependencies + run: npm ci + - name: Run Lint script + run: npm run lint