-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(expo): add an Expo config plugin to simplify enabling Next Storage
Fixes #750 Co-Authored-By: Bill Spooner <[email protected]>
- Loading branch information
1 parent
db99ba9
commit e570c09
Showing
8 changed files
with
3,121 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@react-native-async-storage/async-storage": minor | ||
--- | ||
|
||
Add an Expo config plugin to simplify enabling Next Storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./plugin/build'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @generated by expo-module-scripts | ||
module.exports = require('expo-module-scripts/eslintrc.base.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('expo-module-scripts/jest-preset-plugin'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { ConfigPlugin} from '@expo/config-plugins'; | ||
import { withGradleProperties } from '@expo/config-plugins'; | ||
|
||
export type AsyncStorageOptions = { | ||
useNextStorage?: boolean; | ||
} | ||
|
||
const withUseNextStorage: ConfigPlugin<AsyncStorageOptions> = (config, { useNextStorage = false }) => { | ||
if (!useNextStorage) { | ||
return config; | ||
} | ||
|
||
return withGradleProperties(config, (config) => { | ||
config.modResults.push({ | ||
key: 'AsyncStorage_useNextStorage', | ||
value: 'true', | ||
type: 'property', | ||
}); | ||
|
||
return config; | ||
}); | ||
}; | ||
|
||
const DEFAULT_OPTS: AsyncStorageOptions = { | ||
useNextStorage: false, | ||
} | ||
|
||
const withAsyncStorage: ConfigPlugin<AsyncStorageOptions> = (config, props) => { | ||
const normalizedProps = { ...DEFAULT_OPTS, ...props }; | ||
config = withUseNextStorage(config, normalizedProps); | ||
return config; | ||
}; | ||
|
||
export default withAsyncStorage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "expo-module-scripts/tsconfig.plugin", | ||
"compilerOptions": { | ||
"outDir": "build", | ||
"rootDir": "src" | ||
}, | ||
"include": ["./src"], | ||
"exclude": ["**/__mocks__/*", "**/__tests__/*"] | ||
} |
Oops, something went wrong.