Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: Upgrade to @react-native-async-storage/async-storage #8250

Merged
merged 9 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1072,9 +1072,9 @@ workflows:
- integ_vue_auth
- integ_rn_ios_storage
- integ_rn_ios_storage_multipart_progress
- integ_rn_android_storage_multipart_progress
- integ_rn_ios_push_notifications
- integ_rn_android_storage
- integ_rn_android_storage_multipart_progress
- integ_datastore_auth
- integ_duplicate_packages
- post_release:
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ Our default implementation works with Amazon Web Services (AWS), but AWS Amplify

## Notice:

### Amplify@3.x.x has breaking changes. Please see the breaking changes below:
### Amplify 4.x.x has breaking changes for React Native. Please see the breaking changes below:

-

### Amplify 3.x.x has breaking changes. Please see the breaking changes below:

- `AWS.credentials` and `AWS.config` don’t exist anymore anywhere in Amplify JavaScript.
- Both options will not be available to use in version 3. You will not be able to use and set your own credentials.
amhinson marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
52 changes: 51 additions & 1 deletion packages/amazon-cognito-identity-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/preset-react": "^7.0.0",
"@react-native-async-storage/async-storage": "^1.13.0",
"babel-loader": "^8.0.6",
"cross-env": "^3.1.4",
"eslint": "^3.19.0",
Expand All @@ -90,8 +91,57 @@
"eslint-plugin-standard": "^3.0.1",
"jsdoc": "^3.4.0",
"react": "^16.0.0",
"react-native": "^0.44.0",
"react-native": "^0.59.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to move to version 0.60.0 and above now that we are releasing a new major version?

"rimraf": "^2.5.4",
"webpack": "^3.5.5"
},
"peerDependencies": {
"@react-native-async-storage/async-storage": "^1.13.0"
},
"jest": {
"globals": {
"ts-jest": {
"diagnostics": false,
"tsConfig": {
"lib": [
"es5",
"es2015",
"dom",
"esnext.asynciterable",
"es2017.object"
],
"allowJs": true,
"esModuleInterop": true
}
}
},
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
},
"preset": "ts-jest",
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json",
"jsx"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost/",
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 0,
"lines": 0,
"statements": 0
}
},
"coveragePathIgnorePatterns": [
"/node_modules/",
"dist",
"es",
"lib"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { AsyncStorage } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';

const MEMORY_KEY_PREFIX = '@MemoryStorage:';
let dataMemory = {};
Expand Down
4 changes: 3 additions & 1 deletion packages/cache/__mocks__/AsyncStorage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const AsyncStorage = jest.genMockFromModule('react-native');
const AsyncStorage = jest.genMockFromModule(
'@react-native-async-storage/async-storage'
);

var store = {};
var curSize = 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/src/AsyncStorageCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { StorageCache } from './StorageCache';
import { defaultConfig, getCurrTime } from './Utils';
import { AsyncStorage } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { ICache } from './types';
import { ConsoleLogger as Logger } from '@aws-amplify/core';

Expand Down
4 changes: 4 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
},
"homepage": "https://aws-amplify.github.io/",
"devDependencies": {
"@react-native-async-storage/async-storage": "^1.13.0",
"find": "^0.2.7",
"genversion": "^2.2.0",
"prepend-file": "^1.3.1",
Expand All @@ -62,6 +63,9 @@
"universal-cookie": "^4.0.4",
"zen-observable-ts": "0.8.19"
},
"peerDependencies": {
"@react-native-async-storage/async-storage": "^1.13.0"
},
"jest": {
"globals": {
"ts-jest": {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/RNComponents/reactnative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
* and limitations under the License.
*/

export { Linking, AppState, AsyncStorage } from 'react-native';
import { Linking, AppState } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
export { Linking, AppState, AsyncStorage };
2 changes: 1 addition & 1 deletion packages/core/src/StorageHelper/reactnative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
import { AsyncStorage } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';

const MEMORY_KEY_PREFIX = '@MemoryStorage:';
let dataMemory = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AsyncStorage } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';

// See: https://reactnative.dev/docs/asyncstorage
// See: https://react-native-async-storage.github.io/async-storage/
export function createInMemoryStore() {
return AsyncStorage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ jest.mock('react-native', () => ({
currentState: 'active',
addEventListener: (event, callback) => callback('active'),
},
AsyncStorage: {
getItem: () => new Promise(res => res('item')),
setItem: jest.fn(),
},
DeviceEventEmitter: {
addListener: jest.fn(),
},
Expand All @@ -29,6 +25,11 @@ jest.mock('react-native', () => ({
},
}));

jest.mock('@react-native-async-storage/async-storage', () => ({
getItem: () => new Promise(res => res('item')),
setItem: jest.fn(),
}));

jest.mock('@react-native-community/push-notification-ios', () => ({
requestPermissions: () => {},
getInitialNotification: new Promise(res => res('notification')),
Expand Down
2 changes: 1 addition & 1 deletion packages/pushnotification/src/PushNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import {
NativeModules,
DeviceEventEmitter,
AsyncStorage,
Platform,
AppState,
} from 'react-native';
import PushNotificationIOS from '@react-native-community/push-notification-ios';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { Amplify, ConsoleLogger as Logger, JS } from '@aws-amplify/core';

const logger = new Logger('Notification');
Expand Down