Skip to content

Commit

Permalink
ci: add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tompsota committed Nov 8, 2024
1 parent dfd16ce commit 6f47ce3
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 26 deletions.
10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

17 changes: 17 additions & 0 deletions .github/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Setup
description: Setup Node.js and install dependencies

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version-file: .nvmrc

- name: Install dependencies
run: |
npm ci
npm ci --prefix example
shell: bash
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI
on:
push:
branches:
- main
paths-ignore:
- '**/*.md'
- '.github/**'
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'
- '.github/**'

jobs:
static-analysis:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Lint files
run: npm run eslint -- --max-warnings=0

- name: Typecheck files
run: npm run typecheck

- name: Format check
run: npm run prettier -- --check

build:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Build package
run: npm run ionic:build
4 changes: 2 additions & 2 deletions example/capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const config: CapacitorConfig = {
appName: 'CapacitorExample',
webDir: 'build',
server: {
androidScheme: 'https'
}
androidScheme: 'https',
},
};

export default config;
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
"eslint": "eslint . --ext ts",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"prettier": "prettier \"**/*.{ts, js, jsx, tsx}\"",
"typecheck": "tsc --noEmit",
"swiftlint": "node-swiftlint",
"ts:build": "tsc",
"build": "npm run clean && tsc && rollup -c rollup.config.js",
Expand All @@ -60,7 +61,7 @@
"rimraf": "^3.0.2",
"rollup": "^2.32.0",
"swiftlint": "^1.0.1",
"typescript": "~5.2.2"
"typescript": "~4.1.5"
},
"peerDependencies": {
"@capacitor/core": "*"
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const prepareMapping = async (): Promise<void> => {
const threats = Threat.getValues();

threats.map((threat, index) => {
threat.value = newValues[index]!;
threat.value = newValues[index];
});
};

Expand All @@ -57,7 +57,7 @@ const toSuspiciousAppInfo = (base64Value: string): SuspiciousAppInfo => {

const setThreatListeners = async <T extends NativeEventEmitterActions>(
callbacks: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>,
) => {
): Promise<void> => {
const [channel, key, malwareKey] = await getThreatChannelData();
await prepareMapping();

Expand Down Expand Up @@ -115,20 +115,21 @@ const setThreatListeners = async <T extends NativeEventEmitterActions>(
});
};

const removeThreatListeners = () => {
const removeThreatListeners = (): void => {
activeListeners.forEach(listener => listener.remove());
};

const startFreeRASP = async <T extends NativeEventEmitterActions>(
config: FreeraspConfig,
reactions: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>,
) => {
): Promise<boolean> => {
await setThreatListeners(reactions);
try {
const { started } = await Freerasp.talsecStart({ config });
return started;
} catch (e: any) {
console.error(`${e.code}: ${e.message}`);
return Promise.reject(`${e.code}: ${e.message}`);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export const getThreatCount = (): number => {

export const itemsHaveType = (data: any[], desiredType: string): boolean => {
return data.every(item => typeof item === desiredType);
};
};
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"allowUnreachableCode": false,
"skipLibCheck": true,
"declaration": true,
"esModuleInterop": true,
"inlineSources": true,
Expand All @@ -14,7 +15,8 @@
"pretty": true,
"sourceMap": true,
"strict": true,
"target": "es2017"
"target": "es2017",
"types": []
},
"files": ["src/index.ts"]
"files": ["src/index.ts"],
}

0 comments on commit 6f47ce3

Please sign in to comment.