Skip to content

Commit

Permalink
build: config eslint and add lint github action (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: axi92 <[email protected]>
  • Loading branch information
0x7061 and axi92 authored Sep 4, 2024
1 parent f68be83 commit e5dbc1e
Show file tree
Hide file tree
Showing 35 changed files with 1,142 additions and 789 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.java]
ij_java_imports_layout = $*, |, javax.**, java.**, |, *

[*.gradle]
indent_size = 4

Expand Down
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"eslint-plugin-prettier"
],
"rules": {
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"no-void": "off",
"max-len": "off",
"no-console": "off",
Expand All @@ -40,5 +42,9 @@
"useTabs": false
}
]
}
},
"ignorePatterns": [
"node_modules/*",
"dist/*"
]
}
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: 'monthly'
28 changes: 28 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Cache
on:
pull_request:
types:
- closed
jobs:
clear:
runs-on: ubuntu-latest
steps:
- name: Execute
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint
on:
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]
permissions:
id-token: write
attestations: write
jobs:
All:
runs-on: macos-latest
permissions:
id-token: write
attestations: write
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install swiftlint
run: brew install swiftlint
- name: Cache node_modules
id: node-modules
uses: actions/cache@v4
with:
path: |
node_modules
test-app/node_modules
key: node-modules
- run: npm i
- run: npm run lint
- run: npm pack
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: package
path: '${{ github.workspace }}/*.tgz'
- name: Attest
uses: actions/attest-build-provenance@v1
with:
subject-path: '${{ github.workspace }}/*.tgz'
21 changes: 21 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Semantic PR Title'

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139 changes: 139 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Test
on:
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]
jobs:
Web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache node_modules
id: node-modules
uses: actions/cache@v4
with:
path: |
node_modules
test-app/node_modules
key: node-modules
- name: NPM Install
run: npm i
- name: Test Web
run: npm run verify:web
iOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: '5.10.0'
- name: Get Swift Version
run: swift --version
- name: Get Xcode version
env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app
run: xcodebuild -version
- name: Cache Pods
id: pods
uses: actions/cache@v4
with:
path: |
ios/Pods
test-app/ios/App/Pods
key: pods
- name: Cache Xcode DerivedData
uses: irgaly/[email protected]
with:
key: xcode-deriveddata
restore-keys: xcode-deriveddata
- name: Install Cocoapods
run: gem install cocoapods
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache node_modules
id: node-modules
uses: actions/cache@v4
with:
path: |
node_modules
test-app/node_modules
key: node-modules
- name: Pod Install
run: cd ios; pod install; cd -
- name: NPM Install
run: npm i
- name: Test iOS
env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app
run: |
cd ios
xcodebuild \
-quiet \
-workspace Plugin.xcworkspace \
-scheme Plugin \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \
test || exit 1
Android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Install Android SDK
uses: android-actions/setup-android@v3
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
android/.gradle
test-app/android/.gradle
~/.gradle/caches
key: gradle
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Cache AVD
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache node_modules
id: node-modules
uses: actions/cache@v4
with:
path: |
node_modules
test-app/node_modules
key: node-modules
- name: NPM Install
run: npm i
- name: Test Android
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
working-directory: android/
script: ./gradlew clean build test connectedAndroidTest
2 changes: 2 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plugins:
- prettier-plugin-java
6 changes: 4 additions & 2 deletions ios/.swiftlint.yml → .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ disabled_rules:
- force_cast

excluded:
- Carthage
- Pods
- ios/Pods
- node_modules
- test-app/ios/App/Pods
- test-app/node_modules
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ npm install @evva-sfw/capacitor-secure-storage-plugin

For version lower than 5 please refer to https://github.com/martinkasa/capacitor-secure-storage-plugin

## Compatibility

### iOS 15.0+
### Android API Level 29+

## Usage

```typescript
Expand Down Expand Up @@ -112,15 +117,12 @@ async getUsername(key: string) {

### iOS

This plugin uses SimpleKeyChain under the hood for iOS.
This plugin uses the SimpleKeychain Swift library for iOS.

### Android

On Android it is implemented by AndroidKeyStore and SharedPreferences. Source: [Apriorit](https://www.apriorit.com/dev-blog/432-using-androidkeystore)

> **Warning**
> For Android API < 18 values are stored as simple base64 encoded strings.
### Web

There is no secure storage in browser (not because it is not implemented by this plugin, but it does not exist at all). Values are stored in LocalStorage, but they are at least base64 encoded. Plugin adds 'cap*sec*' prefix to keys to avoid conflicts with other data stored in LocalStorage.
Loading

0 comments on commit e5dbc1e

Please sign in to comment.