Skip to content

Commit

Permalink
Merge pull request #3 from cursorinsight/denes/workflows
Browse files Browse the repository at this point in the history
chore: Add GitHub workflows
  • Loading branch information
denessapi authored Mar 7, 2024
2 parents a74a59b + 0a10027 commit 4ff4445
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 18 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
dist
example
29 changes: 29 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
54 changes: 54 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
dist
example
Empty file modified android/gradlew
100644 → 100755
Empty file.
Empty file modified example/android/gradlew
100644 → 100755
Empty file.
11 changes: 5 additions & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ export interface CapacitorTrapPlugin {
/**
* Add custom metadata
*/
addCustomMetadata(options: { key: string, value: any }): Promise<void>;
addCustomMetadata(options: { key: string; value: any }): Promise<void>;

/**
* Checks permission for the specific collector. Returns true if the collector
* has the required permission.
*/
checkPermission(options: { collector: CollectorTypes })
: Promise<PermissionResult>;
checkPermission(options: {
collector: CollectorTypes;
}): Promise<PermissionResult>;

/**
* Initialize the plugin
Expand All @@ -34,7 +35,7 @@ export interface CapacitorTrapPlugin {
/**
* Request permission for the specific collector.
*/
requestPermission(options: { collector: CollectorTypes }) : Promise<void>;
requestPermission(options: { collector: CollectorTypes }): Promise<void>;

/**
* Start data collection
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ const CapacitorTrap = registerPlugin<CapacitorTrapPlugin>('CapacitorTrap', {

export * from './definitions';
export { TrapConfig } from './config';
export { CapacitorTrap };
export { CapacitorTrap };
20 changes: 13 additions & 7 deletions src/web.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,13 +14,14 @@ export class CapacitorTrapWeb extends WebPlugin implements CapacitorTrapPlugin {
}

// eslint-disable-next-line
addCustomMetadata(options : {key: string, value: any }): Promise<void> {
addCustomMetadata(options: { key: string; value: any }): Promise<void> {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
checkPermission(options: { collector: CollectorTypes; })
: Promise<PermissionResult> {
checkPermission(options: {
collector: CollectorTypes;
}): Promise<PermissionResult> {
throw new Error('Method not implemented.');
}

Expand All @@ -24,17 +30,17 @@ export class CapacitorTrapWeb extends WebPlugin implements CapacitorTrapPlugin {
}

// eslint-disable-next-line
configure(options: { config: TrapConfigurationType } ): Promise<void> {
configure(options: { config: TrapConfigurationType }): Promise<void> {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
removeCustomMetadata(options : { key: string }): Promise<void> {
removeCustomMetadata(options: { key: string }): Promise<void> {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
requestPermission(options: { collector: CollectorTypes; }) : Promise<void> {
requestPermission(options: { collector: CollectorTypes }): Promise<void> {
throw new Error('Method not implemented.');
}

Expand Down

0 comments on commit 4ff4445

Please sign in to comment.