Skip to content

Commit 49bb8d9

Browse files
author
Krzysztof Borowy
authored
[v2] Initial setup
1 parent 7042363 commit 49bb8d9

File tree

89 files changed

+11004
-3490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+11004
-3490
lines changed

.circleci/config.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ jobs:
129129
name: Lint check
130130
command: yarn test:lint
131131

132-
"Test: flow":
132+
"Test: types":
133133
<<: *js_defaults
134134
steps:
135135
- *addWorkspace
136136
- run:
137-
name: Flow check
138-
command: yarn test:flow
137+
name: Type check
138+
command: yarn test:types
139139

140140
"Test: iOS e2e":
141141
<<: *macos_defaults
@@ -282,25 +282,12 @@ jobs:
282282
# ==============================
283283
workflows:
284284
version: 2
285-
"Testing":
285+
build_and_test_wip:
286286
jobs:
287287
- "Setup environment"
288288
- "Test: lint":
289289
requires:
290290
- "Setup environment"
291-
- "Test: flow":
291+
- "Test: types":
292292
requires:
293293
- "Setup environment"
294-
- "Test: iOS e2e":
295-
requires:
296-
- "Test: lint"
297-
- "Test: flow"
298-
- "Build: Android release apk":
299-
requires:
300-
- "Test: lint"
301-
- "Test: flow"
302-
- "Test: Android e2e":
303-
requires:
304-
- "Test: lint"
305-
- "Test: flow"
306-
- "Build: Android release apk"

.eslintrc

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
11
{
2-
"extends": "@react-native-community",
3-
"globals": {
4-
"it": true,
5-
"expect": true,
6-
"element": true,
7-
"describe": true,
8-
"by": true,
9-
"device": true,
10-
"beforeAll": true,
11-
"beforeEach": true,
12-
"afterAll": true,
13-
"jest": true,
14-
"jasmine": true
15-
}
16-
}
2+
"extends": "@react-native-community"
3+
}

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
node_modules/
99
npm-debug.log
1010
yarn-error.log
11-
11+
lerna-debug.log
1212

1313
# Xcode
1414
#
@@ -29,7 +29,7 @@ DerivedData
2929
*.ipa
3030
*.xcuserstate
3131
project.xcworkspace
32-
32+
3333

3434
# Android/IntelliJ
3535
#
@@ -45,4 +45,9 @@ buck-out/
4545
*.keystore
4646

4747
# Editor config
48-
.vscode
48+
.vscode
49+
50+
51+
# Async Storage
52+
core/build
53+
storages/**/build

.prettierrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"requirePragma": true,
2+
"requirePragma": false,
33
"singleQuote": true,
44
"trailingComma": "all",
55
"bracketSpacing": false,
66
"jsxBracketSameLine": true,
77
"parser": "flow"
8-
}
8+
}

CONTRIBUTING.md

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,3 @@
1-
# Contributing to React Native Async Storage
1+
# Contributing to Async Storage
22

3-
Thank you for helping out with Async Storage!
4-
We'd like to make contributions as pleasent as possible, so here's a small guide of how we see it. Happy to hear your feedback about anything, so please let us know.
5-
6-
7-
## Tests
8-
We use `flow` for type check, `eslint` with `prettier` for linting/formatting, `jest/detox` for tests (unit and e2e). All tests are run on CircleCI for all opened pull requests, but you should use them locally when making changes.
9-
10-
* `yarn test`: Run all tests, except for e2e (see note below).
11-
* `yarn test:lint`: Run `eslint` check.
12-
* `yarn test:flow`: Run `flow` type check.
13-
* `yarn test:e2e:<ios|android>`: Runs e2e tests. Before you can run it, you should build the app that can be run, by using `yarn build:e2e:<ios|android>`.
14-
15-
16-
## Sending a pull request
17-
When you're sending a pull request:
18-
19-
* Communication is a key. If you want fix/add something, please open new/find existing issue, so we can discuss it.
20-
* We prefer small pull requests focused on one change, as those are easier to test/check.
21-
* Please make sure that all tests are passing on your local machine.
22-
* Follow the template when opening a PR.
23-
24-
25-
## Commits and versioning
26-
All PRs are squashed into `master` branch and wrapped up in a single commit, following [conventional commit message](https://www.conventionalcommits.org/en/v1.0.0-beta.3). Combined with [semantic versioning](https://semver.org/), this allows us to have a frequent releases of the library.
27-
28-
*Note*: We don't force this convention on Pull Requests from contributors, but it's a clean way to see what type of changes are made, so feel free to follow it.
29-
30-
31-
Most notably prefixes you'll see:
32-
33-
* **fix**: Bug fixes, triggers *patch* release
34-
* **feat**: New feature implemented, triggers *minor*
35-
* **chore**: Changes that are not affecting end user (CI config changes, scripts, ["grunt work"](https://stackoverflow.com/a/26944812/3510245))
36-
* **docs**: Documentation changes.
37-
* **perf**: A code change that improves performance.
38-
* **refactor**: A code change that neither fixes a bug nor adds a feature.
39-
* **test**: Adding missing tests or correcting existing tests.
40-
41-
42-
## Release process
43-
We use [Semantic Release](http://semantic-release.org) to automatically release new versions of the library when changes are merged into `master` branch, which we plan to keep stable. Bug fixes take priority in the release order.
44-
45-
## Reporting issues
46-
You can report issues on our [bug tracker](https://github.com/react-native-community/react-native-async-storage/issues). Please search for existing issues and follow the issue template when opening an one.
47-
48-
49-
## License
50-
By contributing to React Native Async Storage, you agree that your contributions will be licensed under the **MIT** license.
3+
Todo.

README.md

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,13 @@
1-
# React Native Async Storage
1+
# Async Storage
22

3-
An asynchronous, unencrypted, persistent, key-value storage system for React Native.
3+
A storage system for React Native.
44

5+
## Work in progress
56

6-
## Getting Started
7+
Async Storage v2 is still under development.
78

9+
If you're looking for published and operational Async Storage version, please check out [`LEGACY`](https://github.com/react-native-community/async-storage/tree/LEGACY) branch.
810

9-
```
10-
# Install
11-
$ yarn add @react-native-community/async-storage
11+
If you'd like to see the progress of v2, [please visit Project page.](https://github.com/react-native-community/async-storage/projects/1)
1212

13-
# Link
14-
$ react-native link @react-native-community/async-storage
15-
```
1613

17-
See docs for [manual linking guide.](docs/Linking.md)
18-
19-
**Note:** For iOS project using `pods`, run:
20-
```
21-
$ cd ios/ && pod install
22-
```
23-
24-
25-
## Usage
26-
27-
### Import
28-
29-
```js
30-
import AsyncStorage from '@react-native-community/async-storage';
31-
```
32-
33-
### Store data
34-
```jsx
35-
36-
storeData = async () => {
37-
try {
38-
await AsyncStorage.setItem('@storage_Key', 'stored value')
39-
} catch (e) {
40-
// saving error
41-
}
42-
}
43-
44-
```
45-
46-
### Read data
47-
```jsx
48-
49-
getData = async () => {
50-
try {
51-
const value = await AsyncStorage.getItem('@storage_Key')
52-
if(value !== null) {
53-
// value previously stored
54-
}
55-
} catch(e) {
56-
// error reading value
57-
}
58-
}
59-
60-
```
61-
### Advanced
62-
See docs for [api and more examples](docs/API.md) or [advanced usages](docs/advanced).
63-
64-
## Writing tests
65-
66-
Using [Jest](https://jestjs.io/) for testing? Make sure to check out [docs on how to integrate it with this module.](./docs/Jest-integration.md)
67-
68-
## Contribution
69-
70-
See the [CONTRIBUTING](CONTRIBUTING.md) file for how to help out.
71-
72-
## License
73-
74-
MIT

babel.config.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
2+
presets: ['@babel/preset-typescript'],
33
plugins: [
4-
[
5-
'module-resolver',
6-
{
7-
alias: {
8-
'@react-native-community/async-storage': './lib/index',
9-
},
10-
cwd: 'babelrc',
11-
},
12-
],
4+
'@babel/proposal-class-properties',
5+
'@babel/proposal-object-rest-spread',
136
],
147
};

core/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@react-native-community/async-storage",
3+
"version": "2.0.0",
4+
"main": "build/index.js",
5+
"files": ["build/**/*"],
6+
"types": "types/index.d.ts",
7+
"author": "Krzysztof Borowy <dev@krizzu.dev>",
8+
"license": "MIT",
9+
"scripts": {
10+
"build": "babel src/ --root-mode upward --out-dir build/ --extensions .ts --ignore build/**/* --ignore types/* --source-maps inline",
11+
"clean": "rm build -rf",
12+
"start": "yarn build:lib --watch"
13+
}
14+
}

core/src/AsyncStorage.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class AsyncStorage implements IAsyncStorage {
2+
backend: IStorageBackend;
3+
4+
constructor(storageBackend: IStorageBackend) {
5+
this.backend = storageBackend;
6+
}
7+
8+
set(): Promise<void> {
9+
return Promise.resolve(undefined);
10+
}
11+
}
12+
13+
export default AsyncStorage;

core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default as AsyncStorage} from './AsyncStorage';

0 commit comments

Comments
 (0)