From 658365f584a4a8ae7932c9cca45165f20c49ecc3 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Tue, 2 Jul 2024 17:37:21 +0200 Subject: [PATCH] chore: release setup Signed-off-by: Timo Glastra --- .github/workflows/ci.yaml | 84 ++++++++++++++++++++++++++ .npmignore | 2 +- .release-it.json | 16 +++++ CHANGELOG.md | 11 ---- app.plugin.js | 2 +- ausweis-example/app.json | 5 +- ausweis-example/app/index.tsx | 17 ++---- ausweis-example/babel.config.js | 10 +-- ausweis-example/tsconfig.json | 11 +--- biome.json | 35 +++++++++++ package.json | 18 +++--- plugin/src/index.ts | 19 ++---- plugin/src/withAndroidAusweisSdk.ts | 4 +- plugin/src/withIosAusweisSdk.ts | 78 +++++++++++------------- plugin/tsconfig.json | 2 +- pnpm-lock.yaml | 94 ++++++++++++++++++++++++++++- src/AusweisSdk.types.ts | 4 +- src/AusweisSdkModule.ts | 4 +- src/index.ts | 28 +++------ 19 files changed, 308 insertions(+), 136 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .release-it.json delete mode 100644 CHANGELOG.md create mode 100644 biome.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..aa78361 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,84 @@ +name: Pipeline + +on: + push: + branches: + - main + + pull_request: + + workflow_dispatch: + inputs: + release-type: + description: "Type of release (major, minor, patch, alpha)" + required: true + default: alpha + type: choice + options: + - major + - minor + - patch + - alpha + +jobs: + continuous-integration: + name: "Continuous Integration" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Install dependencies + run: pnpm install + + - name: Style + run: pnpm style:check + + - name: Build + run: pnpm build + + - name: Check types + run: pnpm types:check + + continuous-deployment: + if: github.event_name == 'workflow_dispatch' + + name: 'Continuous Deployment' + runs-on: ubuntu-latest + needs: ['continuous-integration'] + + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Set git configuration + run: | + git config user.name "Animo Solutions" + git config user.email "development@animo.id" + + - name: Publish + id: publish + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN + + if [ ${{ inputs.release-type }} == 'alpha' ]; then + pnpm release --preRelease=alpha + else + pnpm release -i=${{ inputs.release-type }} + fi \ No newline at end of file diff --git a/.npmignore b/.npmignore index 626eb60..33265d5 100644 --- a/.npmignore +++ b/.npmignore @@ -13,6 +13,6 @@ __tests__ /android/build/ /ausweis-example/ -./src +src plugin/src tsconfig.json \ No newline at end of file diff --git a/.release-it.json b/.release-it.json new file mode 100644 index 0000000..da9bcc6 --- /dev/null +++ b/.release-it.json @@ -0,0 +1,16 @@ +{ + "github": { + "release": true + }, + "npm": { + "skipChecks": true, + "tag": "latest" + }, + "git": { + "push": false, + "commit": false, + "requireCommits": true, + "tagAnnotation": "${version}", + "requireBranch": "main" + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index a2ba70d..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# Changelog - -## Unpublished - -### 🛠 Breaking changes - -### 🎉 New features - -### 🐛 Bug fixes - -### 💡 Others diff --git a/app.plugin.js b/app.plugin.js index c380863..8f59b43 100644 --- a/app.plugin.js +++ b/app.plugin.js @@ -1 +1 @@ -module.exports = require('./plugin/build'); \ No newline at end of file +module.exports = require('./plugin/build') diff --git a/ausweis-example/app.json b/ausweis-example/app.json index 150724f..5fa120b 100644 --- a/ausweis-example/app.json +++ b/ausweis-example/app.json @@ -6,10 +6,7 @@ "orientation": "portrait", "scheme": "ausweis-example", "userInterfaceStyle": "automatic", - "plugins": [ - "expo-router", - "../app.plugin.js" - ], + "plugins": ["expo-router", "../app.plugin.js"], "experiments": { "typedRoutes": true }, diff --git a/ausweis-example/app/index.tsx b/ausweis-example/app/index.tsx index a2408a5..d3733ae 100644 --- a/ausweis-example/app/index.tsx +++ b/ausweis-example/app/index.tsx @@ -1,14 +1,9 @@ -import { View, Text, StyleSheet } from "react-native"; +import { StyleSheet, Text, View } from 'react-native' export default function App() { - return ( - - Hello - - ); + return ( + + Hello + + ) } diff --git a/ausweis-example/babel.config.js b/ausweis-example/babel.config.js index 7e9fca3..9f057ea 100644 --- a/ausweis-example/babel.config.js +++ b/ausweis-example/babel.config.js @@ -1,6 +1,6 @@ module.exports = (api) => { - api.cache(true); - return { - presets: ["babel-preset-expo"], - }; -}; + api.cache(true) + return { + presets: ['babel-preset-expo'], + } +} diff --git a/ausweis-example/tsconfig.json b/ausweis-example/tsconfig.json index 909e901..ce27fee 100644 --- a/ausweis-example/tsconfig.json +++ b/ausweis-example/tsconfig.json @@ -3,15 +3,8 @@ "compilerOptions": { "strict": true, "paths": { - "@/*": [ - "./*" - ] + "@/*": ["./*"] } }, - "include": [ - "**/*.ts", - "**/*.tsx", - ".expo/types/**/*.ts", - "expo-env.d.ts" - ] + "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"] } diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..27e72e9 --- /dev/null +++ b/biome.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.1/schema.json", + "formatter": { + "lineWidth": 120, + "indentStyle": "space" + }, + "javascript": { + "parser": { + "unsafeParameterDecoratorsEnabled": true + }, + "formatter": { + "semicolons": "asNeeded", + "quoteStyle": "single", + "trailingCommas": "es5", + "lineWidth": 120, + "indentStyle": "space" + } + }, + "json": { + "parser": { + "allowComments": true + } + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true + }, + "vcs": { + "useIgnoreFile": true, + "clientKind": "git", + "enabled": true + } +} diff --git a/package.json b/package.json index a6882ac..de0018b 100644 --- a/package.json +++ b/package.json @@ -5,19 +5,15 @@ "main": "build/index.js", "types": "build/index.d.ts", "scripts": { - "build": "expo-module build", - "clean": "expo-module clean", - "prepublishOnly": "expo-module prepublishOnly", + "build": "EXPO_NONINTERACTIVE=1 expo-module build && EXPO_NONINTERACTIVE=1 expo-module build plugin", + "style:check": "biome check --unsafe", + "style:fix": "biome check --write --unsafe", + "types:check": "EXPO_NONINTERACTIVE=1 expo-module typecheck && EXPO_NONINTERACTIVE=1 expo-module plugin typecheck", "expo-module": "expo-module", "open:ios": "xed example/ios", "open:android": "open -a \"Android Studio\" example/android" }, - "keywords": [ - "react-native", - "expo", - "ausweis-sdk", - "AusweisSdk" - ], + "keywords": ["react-native", "expo", "ausweis-sdk", "AusweisSdk"], "repository": "https://github.com/animo/expo-ausweis-sdk", "bugs": { "url": "https://github.com/animo/expo-ausweis-sdk/issues" @@ -26,10 +22,10 @@ "license": "Apache-2.0", "homepage": "https://github.com/animo/expo-ausweis-sdk#readme", "dependencies": { - "@expo/config-plugins": "^8.0.6", - "resolve-from": "^5.0.0" + "@expo/config-plugins": "^8.0.6" }, "devDependencies": { + "@biomejs/biome": "1.8.1", "@types/node": "^20.14.9", "@types/react": "^18.0.25", "@types/resolve-from": "^5.0.1", diff --git a/plugin/src/index.ts b/plugin/src/index.ts index 7f4fa3c..bf08b00 100644 --- a/plugin/src/index.ts +++ b/plugin/src/index.ts @@ -1,17 +1,10 @@ -import { - createRunOncePlugin, - type ConfigPlugin, - withPlugins, -} from "@expo/config-plugins"; +import { type ConfigPlugin, createRunOncePlugin, withPlugins } from '@expo/config-plugins' -import { withAndroidAusweisSdk } from "./withAndroidAusweisSdk"; -import { withIosAusweisSdk } from "./withIosAusweisSdk"; +import { withAndroidAusweisSdk } from './withAndroidAusweisSdk' +import { withIosAusweisSdk } from './withIosAusweisSdk' const withAusweisSdk: ConfigPlugin = (config) => { - return withPlugins(config, [withAndroidAusweisSdk, withIosAusweisSdk]); -}; + return withPlugins(config, [withAndroidAusweisSdk, withIosAusweisSdk]) +} -export default createRunOncePlugin( - withAusweisSdk, - "@animo-id/expo-ausweis-sdk", -); +export default createRunOncePlugin(withAusweisSdk, '@animo-id/expo-ausweis-sdk') diff --git a/plugin/src/withAndroidAusweisSdk.ts b/plugin/src/withAndroidAusweisSdk.ts index e85920b..d508ac5 100644 --- a/plugin/src/withAndroidAusweisSdk.ts +++ b/plugin/src/withAndroidAusweisSdk.ts @@ -1,6 +1,6 @@ -import { type ConfigPlugin, withAndroidManifest, withDangerousMod, withMainApplication } from '@expo/config-plugins' -import path from 'node:path' import fs from 'node:fs' +import path from 'node:path' +import { type ConfigPlugin, withAndroidManifest, withDangerousMod, withMainApplication } from '@expo/config-plugins' import { addAndroidImports } from './util' /** diff --git a/plugin/src/withIosAusweisSdk.ts b/plugin/src/withIosAusweisSdk.ts index 29f2276..4ab2a25 100644 --- a/plugin/src/withIosAusweisSdk.ts +++ b/plugin/src/withIosAusweisSdk.ts @@ -1,52 +1,46 @@ -import type { ConfigPlugin } from "@expo/config-plugins"; +import type { ConfigPlugin } from '@expo/config-plugins' -import path from "node:path"; -import fs from "node:fs/promises"; -import { withDangerousMod } from "@expo/config-plugins"; -import { - mergeContents, - MergeResults, -} from "@expo/config-plugins/build/utils/generateCode"; +import fs from 'node:fs/promises' +import path from 'node:path' +import { withDangerousMod } from '@expo/config-plugins' +import { type MergeResults, mergeContents } from '@expo/config-plugins/build/utils/generateCode' -const podSource = `pod 'AusweisApp2', :path => File.join(File.dirname(\`node --print "require.resolve('@animo-id/expo-ausweis-sdk/package.json')"\`), "ios/Specs")`; +const podSource = `pod 'AusweisApp2', :path => File.join(File.dirname(\`node --print "require.resolve('@animo-id/expo-ausweis-sdk/package.json')"\`), "ios/Specs")` export function addAusweisApp2Pod(src: string): MergeResults { - return mergeContents({ - tag: "@animo-id/expo-ausweis-sdk", - src, - newSrc: podSource, - anchor: /use_native_modules/, - offset: 0, - comment: "#", - }); + return mergeContents({ + tag: '@animo-id/expo-ausweis-sdk', + src, + newSrc: podSource, + anchor: /use_native_modules/, + offset: 0, + comment: '#', + }) } const withIosAusweisApp2Pod: ConfigPlugin = (config) => { - return withDangerousMod(config, [ - "ios", - async (config) => { - const filePath = path.join( - config.modRequest.platformProjectRoot, - "Podfile", - ); - const contents = await fs.readFile(filePath, "utf-8"); - const results = addAusweisApp2Pod(contents); - - if (!results.didMerge) { - console.log( - "ERROR: Cannot add AusweisApp2 to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.", - ); - return config; - } - - await fs.writeFile(filePath, results.contents); - return config; - }, - ]); -}; + return withDangerousMod(config, [ + 'ios', + async (config) => { + const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile') + const contents = await fs.readFile(filePath, 'utf-8') + const results = addAusweisApp2Pod(contents) + + if (!results.didMerge) { + console.log( + "ERROR: Cannot add AusweisApp2 to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile." + ) + return config + } + + await fs.writeFile(filePath, results.contents) + return config + }, + ]) +} const withIosAusweisSdk: ConfigPlugin = (config) => { - return withIosAusweisApp2Pod(config); -}; + return withIosAusweisApp2Pod(config) +} -export { withIosAusweisSdk }; +export { withIosAusweisSdk } diff --git a/plugin/tsconfig.json b/plugin/tsconfig.json index 059701c..354bddb 100644 --- a/plugin/tsconfig.json +++ b/plugin/tsconfig.json @@ -6,4 +6,4 @@ }, "include": ["./src"], "exclude": ["**/__mocks__/*", "**/__tests__/*"] -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6cb5fd6..da7b032 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,10 +20,10 @@ importers: react-native: specifier: '*' version: 0.74.3(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(react@18.3.1) - resolve-from: - specifier: ^5.0.0 - version: 5.0.0 devDependencies: + '@biomejs/biome': + specifier: 1.8.1 + version: 1.8.1 '@types/node': specifier: ^20.14.9 version: 20.14.9 @@ -822,6 +822,59 @@ packages: '@bcoe/v8-coverage@0.2.3': resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + '@biomejs/biome@1.8.1': + resolution: {integrity: sha512-fQXGfvq6DIXem12dGQCM2tNF+vsNHH1qs3C7WeOu75Pd0trduoTmoO7G4ntLJ2qDs5wuw981H+cxQhi1uHnAtA==} + engines: {node: '>=14.21.3'} + hasBin: true + + '@biomejs/cli-darwin-arm64@1.8.1': + resolution: {integrity: sha512-XLiB7Uu6GALIOBWzQ2aMD0ru4Ly5/qSeQF7kk3AabzJ/kwsEWSe33iVySBP/SS2qv25cgqNiLksjGcw2bHT3mw==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [darwin] + + '@biomejs/cli-darwin-x64@1.8.1': + resolution: {integrity: sha512-uMTSxVLMfqkBVqyc25hSn83jBbp+wtWjzM/pHFlKXt3htJuw7FErVGW0nmQ9Sxa9vJ7GcqoltLMl28VQRIMYzg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [darwin] + + '@biomejs/cli-linux-arm64-musl@1.8.1': + resolution: {integrity: sha512-UQ8Wc01J0wQL+5AYOc7qkJn20B4PZmQL1KrmDZh7ot0DvD6aX4+8mmfd/dG5b6Zjo/44QvCKcvkFGCMRYuhWZA==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-arm64@1.8.1': + resolution: {integrity: sha512-3SzZRuC/9Oi2P2IBNPsEj0KXxSXUEYRR2kfRF/Ve8QAfGgrt4qnwuWd6QQKKN5R+oYH691qjm+cXBKEcrP1v/Q==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-x64-musl@1.8.1': + resolution: {integrity: sha512-fYbP/kNu/rtZ4kKzWVocIdqZOtBSUEg9qUhZaao3dy3CRzafR6u6KDtBeSCnt47O+iLnks1eOR1TUxzr5+QuqA==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-linux-x64@1.8.1': + resolution: {integrity: sha512-AeBycVdNrTzsyYKEOtR2R0Ph0hCD0sCshcp2aOnfGP0hCZbtFg09D0SdKLbyzKntisY41HxKVrydYiaApp+2uw==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-win32-arm64@1.8.1': + resolution: {integrity: sha512-6tEd1H/iFKpgpE3OIB7oNgW5XkjiVMzMRPL8zYoZ036YfuJ5nMYm9eB9H/y81+8Z76vL48fiYzMPotJwukGPqQ==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [win32] + + '@biomejs/cli-win32-x64@1.8.1': + resolution: {integrity: sha512-g2H31jJzYmS4jkvl6TiyEjEX+Nv79a5km/xn+5DARTp5MBFzC9gwceusSSB2AkJKqZzY131AiACAWjKrVt5Ijw==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [win32] + '@eslint-community/eslint-utils@4.4.0': resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -6032,6 +6085,41 @@ snapshots: '@bcoe/v8-coverage@0.2.3': {} + '@biomejs/biome@1.8.1': + optionalDependencies: + '@biomejs/cli-darwin-arm64': 1.8.1 + '@biomejs/cli-darwin-x64': 1.8.1 + '@biomejs/cli-linux-arm64': 1.8.1 + '@biomejs/cli-linux-arm64-musl': 1.8.1 + '@biomejs/cli-linux-x64': 1.8.1 + '@biomejs/cli-linux-x64-musl': 1.8.1 + '@biomejs/cli-win32-arm64': 1.8.1 + '@biomejs/cli-win32-x64': 1.8.1 + + '@biomejs/cli-darwin-arm64@1.8.1': + optional: true + + '@biomejs/cli-darwin-x64@1.8.1': + optional: true + + '@biomejs/cli-linux-arm64-musl@1.8.1': + optional: true + + '@biomejs/cli-linux-arm64@1.8.1': + optional: true + + '@biomejs/cli-linux-x64-musl@1.8.1': + optional: true + + '@biomejs/cli-linux-x64@1.8.1': + optional: true + + '@biomejs/cli-win32-arm64@1.8.1': + optional: true + + '@biomejs/cli-win32-x64@1.8.1': + optional: true + '@eslint-community/eslint-utils@4.4.0(eslint@8.57.0)': dependencies: eslint: 8.57.0 diff --git a/src/AusweisSdk.types.ts b/src/AusweisSdk.types.ts index b58463d..2df1b92 100644 --- a/src/AusweisSdk.types.ts +++ b/src/AusweisSdk.types.ts @@ -1,3 +1,3 @@ export type ChangeEventPayload = { - value: string; -}; + value: string +} diff --git a/src/AusweisSdkModule.ts b/src/AusweisSdkModule.ts index c752f7f..492f93a 100644 --- a/src/AusweisSdkModule.ts +++ b/src/AusweisSdkModule.ts @@ -1,5 +1,5 @@ -import { requireNativeModule } from 'expo-modules-core'; +import { requireNativeModule } from 'expo-modules-core' // It loads the native module object from the JSI or falls back to // the bridge module (from NativeModulesProxy) if the remote debugger is on. -export default requireNativeModule('AusweisSdk'); +export default requireNativeModule('AusweisSdk') diff --git a/src/index.ts b/src/index.ts index 4800b78..2311d61 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,31 +1,23 @@ -import { - NativeModulesProxy, - EventEmitter, - Subscription, -} from "expo-modules-core"; +import { EventEmitter, NativeModulesProxy, type Subscription } from 'expo-modules-core' -import AusweisSdkModule from "./AusweisSdkModule"; -import { ChangeEventPayload } from "./AusweisSdk.types"; +import { ChangeEventPayload } from './AusweisSdk.types' +import AusweisSdkModule from './AusweisSdkModule' // Get the native constant value. -export const PI = AusweisSdkModule.PI; +export const PI = AusweisSdkModule.PI export function hello(): string { - return AusweisSdkModule.hello(); + return AusweisSdkModule.hello() } export async function setValueAsync(value: string) { - return await AusweisSdkModule.setValueAsync(value); + return await AusweisSdkModule.setValueAsync(value) } -const emitter = new EventEmitter( - AusweisSdkModule ?? NativeModulesProxy.AusweisSdk, -); +const emitter = new EventEmitter(AusweisSdkModule ?? NativeModulesProxy.AusweisSdk) -export function addChangeListener( - listener: (event: ChangeEventPayload) => void, -): Subscription { - return emitter.addListener("onChange", listener); +export function addChangeListener(listener: (event: ChangeEventPayload) => void): Subscription { + return emitter.addListener('onChange', listener) } -export { ChangeEventPayload }; +export { ChangeEventPayload }