Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage

- name: Run config plugin tests
run: yarn test:plugin --runInBand

build-library:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react-refresh": "^0.4.3",
"expo": "^51.0.0",
"expo-module-scripts": "^3.1.0",
"flow-bin": "^0.259.1",
"hermes-eslint": "^0.15.1",
Expand All @@ -126,9 +127,15 @@
"@types/react": "^18.2.44"
},
"peerDependencies": {
"expo": ">=51.0.0",
"react": "*",
"react-native": "*"
},
"peerDependenciesMeta": {
"expo": {
"optional": true
}
},
"engines": {
"node": ">= 18.0.0"
},
Expand Down
40 changes: 40 additions & 0 deletions plugin/src/__tests__/pluginResolution-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
describe('config plugin package resolution', () => {
it('loads without a direct @expo/config-plugins dependency', () => {
jest.resetModules()
jest.doMock('expo/config-plugins', () => ({
AndroidConfig: {
Permissions: {
withPermissions: (config: unknown) => config
}
},
WarningAggregator: {
addWarningIOS: jest.fn()
},
createRunOncePlugin: (plugin: unknown) => plugin,
withAndroidManifest: (config: unknown) => config,
withInfoPlist: (config: unknown) => config
}))
jest.doMock('@expo/config-plugins', () => {
throw new Error('The plugin must resolve config APIs through expo/config-plugins')
})

let plugin: ((config: Record<string, unknown>) => Record<string, unknown>) | undefined

jest.isolateModules(() => {
plugin = require('../withBLE').default
})

const config = { name: 'test', slug: 'test' }
expect(plugin?.(config)).toBe(config)
})

it('declares Expo as an optional peer dependency', () => {
const packageJson = require('../../../package.json') as {
peerDependencies?: Record<string, string>
peerDependenciesMeta?: Record<string, { optional?: boolean }>
}

expect(packageJson.peerDependencies?.expo).toBe('>=51.0.0')
expect(packageJson.peerDependenciesMeta?.expo?.optional).toBe(true)
})
})
2 changes: 1 addition & 1 deletion plugin/src/__tests__/withBLEAndroidManifest-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AndroidConfig, XML } from '@expo/config-plugins'
import { AndroidConfig, XML } from 'expo/config-plugins'
import { resolve } from 'path'

import {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/withBLE.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AndroidConfig, type ConfigPlugin, createRunOncePlugin, WarningAggregator } from '@expo/config-plugins'
import { AndroidConfig, type ConfigPlugin, createRunOncePlugin, WarningAggregator } from 'expo/config-plugins'

import { withBLEAndroidManifest } from './withBLEAndroidManifest'
import { BackgroundMode, withBLEBackgroundModes } from './withBLEBackgroundModes'
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/withBLEAndroidManifest.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type ConfigPlugin, withAndroidManifest, AndroidConfig } from '@expo/config-plugins'
import { type ConfigPlugin, withAndroidManifest, AndroidConfig } from 'expo/config-plugins'

type InnerManifest = AndroidConfig.Manifest.AndroidManifest['manifest']

type ManifestPermission = InnerManifest['permission']

// TODO: add to `AndroidManifestAttributes` in @expo/config-plugins
// TODO: add to `AndroidManifestAttributes` in expo/config-plugins
type ExtraTools = {
// https://developer.android.com/studio/write/tool-attributes#toolstargetapi
'tools:targetApi'?: string
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/withBLEBackgroundModes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ConfigPlugin, withInfoPlist } from '@expo/config-plugins'
import { type ConfigPlugin, withInfoPlist } from 'expo/config-plugins'

export enum BackgroundMode {
Central = 'central',
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/withBluetoothPermissions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ConfigPlugin, withInfoPlist } from '@expo/config-plugins'
import { type ConfigPlugin, withInfoPlist } from 'expo/config-plugins'

const BLUETOOTH_ALWAYS = 'Allow $(PRODUCT_NAME) to connect to bluetooth devices'

Expand Down
Loading