Skip to content

Commit 8682f25

Browse files
committed
feat: convert plugin to TS
1 parent cd04065 commit 8682f25

File tree

19 files changed

+3308
-3446
lines changed

19 files changed

+3308
-3446
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ node_modules/
4343
npm-debug.log
4444
yarn-error.log
4545

46+
# TypeScript
47+
#
48+
*.tsbuildinfo
49+
4650
# BUCK
4751
buck-out/
4852
\.buckd/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./plugin');
1+
module.exports = require('./plugin/build');

packages/react-native-app-auth/package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
"types": "index.d.ts",
77
"scripts": {
88
"test": "jest",
9-
"lint": "eslint ."
9+
"lint": "eslint .",
10+
"build": "expo-module-scripts build plugin",
11+
"clean": "expo-module-scripts clean plugin",
12+
"lint:plugin": "expo-module-scripts lint plugin",
13+
"test:plugin": "expo-module-scripts test plugin"
1014
},
1115
"files": [
1216
"android",
1317
"ios",
14-
"plugin",
18+
"plugin/build",
19+
"plugin/src",
1520
"app.plugin.js",
1621
"index.d.ts",
1722
"react-native-app-auth.podspec"
@@ -39,11 +44,13 @@
3944
"react-native": ">=0.63.0"
4045
},
4146
"devDependencies": {
47+
"@expo/config-plugins": "~10.1.2",
48+
"@react-native/babel-preset": "0.79.2",
49+
"expo-module-scripts": "^4.1.10",
4250
"jest": "^29.6.3",
4351
"react": "19.0.0",
4452
"react-native": "0.79.2",
45-
"@expo/config-plugins": "~10.1.1",
46-
"@react-native/babel-preset": "0.79.2"
53+
"@types/node": "^22.0.0"
4754
},
4855
"dependencies": {
4956
"invariant": "2.2.4",

packages/react-native-app-auth/plugin/android/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/react-native-app-auth/plugin/ios/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/react-native-app-auth/plugin/ios/info-plist.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/react-native-app-auth/plugin/android/app-build-gradle.js renamed to packages/react-native-app-auth/plugin/src/android/app-build-gradle.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const fs = require('fs');
1+
import * as fs from 'fs';
2+
import { AndroidConfig, withDangerousMod, ConfigPlugin } from '@expo/config-plugins';
3+
import { AppAuthProps } from '../types';
24

3-
const { AndroidConfig, withDangerousMod } = require('@expo/config-plugins');
45
const codeModAndroid = require('@expo/config-plugins/build/android/codeMod');
56

6-
const withAppAuthAppBuildGradle = (rootConfig, props) =>
7+
export const withAppAuthAppBuildGradle: ConfigPlugin<AppAuthProps | undefined> = (rootConfig, props) =>
78
withDangerousMod(rootConfig, [
89
'android',
910
config => {
@@ -35,6 +36,4 @@ const withAppAuthAppBuildGradle = (rootConfig, props) =>
3536

3637
return config;
3738
},
38-
]);
39-
40-
module.exports = { withAppAuthAppBuildGradle };
39+
]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { withAppAuthAppBuildGradle } from './app-build-gradle';
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
interface ExpoConfig {
2+
sdkVersion?: string;
3+
}
4+
15
const EXPO_SDK_MAJOR_VERSION = 53;
26

3-
const isExpo53OrLater = config => {
7+
export const isExpo53OrLater = (config: ExpoConfig): boolean => {
48
const expoSdkVersion = config.sdkVersion || '0.0.0';
59
const [major] = expoSdkVersion.split('.');
610
return Number.parseInt(major, 10) >= EXPO_SDK_MAJOR_VERSION;
7-
};
8-
9-
module.exports = {
10-
isExpo53OrLater,
11-
};
11+
};
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
const { withPlugins, createRunOncePlugin } = require('@expo/config-plugins');
2-
3-
const packageJson = require('../package.json');
4-
5-
const {
1+
import { withPlugins, createRunOncePlugin } from '@expo/config-plugins';
2+
import { AppAuthConfigPlugin, AppAuthProps } from './types';
3+
import {
64
withAppAuthAppDelegate,
75
withAppAuthAppDelegateHeader,
86
withUrlSchemes,
97
withBridgingHeader,
108
withXcodeBuildSettings,
11-
} = require('./ios');
12-
const { withAppAuthAppBuildGradle } = require('./android');
9+
} from './ios';
10+
import { withAppAuthAppBuildGradle } from './android';
11+
12+
const packageJson = require('../../package.json');
1313

14-
const withAppAuth = (config, props) => {
14+
const withAppAuth: AppAuthConfigPlugin = (config, props) => {
1515
// Transform redirectUrls configuration to platform-specific format
16-
const transformedProps = props?.redirectUrls ? {
16+
const transformedProps: AppAuthProps = props?.redirectUrls ? {
1717
ios: {
1818
urlScheme: props.redirectUrls[0]?.split('://')[0], // Extract scheme from first URL
1919
},
2020
android: {
2121
appAuthRedirectScheme: props.redirectUrls[0]?.split('://')[0], // Extract scheme from first URL
2222
},
2323
...props,
24-
} : props;
24+
} : (props || {});
2525

2626
return withPlugins(config, [
2727
// iOS
@@ -36,4 +36,4 @@ const withAppAuth = (config, props) => {
3636
]);
3737
};
3838

39-
module.exports = createRunOncePlugin(withAppAuth, packageJson.name, packageJson.version);
39+
export default createRunOncePlugin(withAppAuth, packageJson.name, packageJson.version);

0 commit comments

Comments
 (0)