Skip to content

Commit f6a3f22

Browse files
authored
refactor: packages (react-native-elements#3291)
1 parent 29224f8 commit f6a3f22

23 files changed

+2968
-3294
lines changed

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
open_collective: react-native-elements
2+
github: react-native-elements

.github/workflows/docs.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
- next
66
paths:
77
- "website/**"
8+
defaults:
9+
run:
10+
working-directory: website
811

912
jobs:
1013
docs:
@@ -29,13 +32,11 @@ jobs:
2932
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
3033
restore-keys: |
3134
${{ runner.os }}-
32-
- name: Install
33-
run: |
34-
yarn
35+
- name: Install dependencies
36+
run: yarn install
3537
- name: Build 🔧
36-
run: |
37-
yarn docs:build
38-
- name: Deploy
38+
run: yarn build
39+
- name: Deploy to gh-pages
3940
uses: peaceiris/actions-gh-pages@v3
4041
with:
4142
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727
run: |
2828
yarn global add codecov
2929
yarn
30-
- name: Testing
31-
run: |
32-
yarn lint
33-
yarn build
34-
yarn test && npx codecov --disable=gcov
30+
- run: yarn lint
31+
- run: yarn typescript
32+
- run: yarn prettier
33+
- run: yarn test && npx codecov --disable=gcov

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage
2+
**/coverage
3+
**/dist

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ Checkout the official
105105
on Expo which uses all of the React Native Elements components.
106106

107107
If you are looking to contribute to the React Native Elements App,
108-
[here](https://github.com/react-native-elements/react-native-elements/tree/example) to
108+
[here](https://github.com/react-native-elements/react-native-elements/tree/next/example) to
109109
view the implementation & Use this command to start example app locally
110110

111111
```bash
112-
yarn start:example
112+
yarn example start
113113
```
114114

115115
## Documentation
@@ -119,7 +119,7 @@ yarn start:example
119119
## Contributing
120120

121121
Interested in contributing to this repo? Check out our
122-
[Contributing Guide](https://reactnativeelements.com/docs/repo/contributing)
122+
[Contributing Guide](https://reactnativeelements.com/docs/repo/contributing), [Setup Guide](https://reactnativeelements.com/docs/repo/contributing#setup)
123123
and submit a PR for a new feature/bug fix.
124124

125125
A big shoutout to all our contributors! You could be here too!
@@ -130,7 +130,7 @@ A big shoutout to all our contributors! You could be here too!
130130

131131
We encourage everyone to contribute & submit PR's especially first-time
132132
contributors. Look for the label `Good First Issue` on the issues. Click
133-
[here](https://github.com/react-native-elements/react-native-elements/labels/%F0%9F%91%B6%20Good%20First%20Issue)
133+
[here](https://github.com/react-native-elements/react-native-elements/labels/Good%20First%20Issue)
134134
to see them.
135135

136136
If there is something you's like to see or request a new feature, please submit

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"ios": "expo start --ios",
1313
"web": "expo start --web",
1414
"eject": "expo eject",
15-
"test": "jest --watchAll",
1615
"build:web": "expo build:web --config ./app.web-build.json --polyfill",
1716
"deploy": "gh-pages -d web-build",
1817
"prettify": "prettier --write . --config ./.prettierrc",
@@ -22,6 +21,7 @@
2221
"dependencies": {
2322
"@expo/vector-icons": "^12.0.5",
2423
"@react-native-community/masked-view": "0.1.10",
24+
"@react-native-elements/base": "^4.0.0-beta.0",
2525
"@react-navigation/drawer": "^5.11.4",
2626
"@react-navigation/native": "^5.8.10",
2727
"@react-navigation/stack": "^5.12.8",

package.json

+37-49
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,59 @@
88
},
99
"scripts": {
1010
"lint": "eslint ./packages --ext .js,.jsx,.ts,.tsx",
11+
"typescript": "tsc --noEmit --composite false",
12+
"prettier": "prettier --check ./packages",
13+
"test": "lerna run test",
1114
"build": "lerna run build",
12-
"test": "jest --runInBand",
1315
"clean-install": "rimraf node_modules && yarn",
14-
"start:example": "yarn --cwd example start",
15-
"docs": "yarn docs:build && yarn docs:serve",
16+
"example": "yarn --cwd example",
1617
"docs:build": "yarn --cwd website build",
18+
"docs:build:api": "yarn --cwd website build:api",
1719
"docs:serve": "yarn --cwd website start",
18-
"docs:lint": "prettier --write 'website/docs/**/*.md'",
19-
"docs:test": "yarn --cwd website test"
20+
"docs:prettier": "prettier --write 'website/docs/**/*.md'",
21+
"docs:test": "yarn --cwd website test",
22+
"postinstall": "husky install",
23+
"lint-staged": "lint-staged"
2024
},
2125
"devDependencies": {
26+
"@testing-library/jest-dom": "^5.11.10",
27+
"@testing-library/react": "^11.2.6",
28+
"@testing-library/react-native": "^7.0.2",
29+
"@types/jest": "^27.4.0",
30+
"@types/react-native": "*",
31+
"babel-jest": "^27.4.6",
32+
"eslint": "^7.9.0",
33+
"husky": "^7.0.4",
34+
"jest": "^27.4.7",
2235
"lerna": "^4.0.0",
23-
"husky": "^7.0.4"
36+
"lint-staged": "^12.1.7",
37+
"react": "^17.0.2",
38+
"react-native": "^0.64.0",
39+
"react-test-renderer": "^16.13.1",
40+
"rimraf": "^3.0.2",
41+
"typescript": "^4.3.5"
2442
},
25-
"jest": {
26-
"preset": "react-native",
27-
"timers": "fake",
28-
"coverageDirectory": "./coverage/",
29-
"testPathIgnorePatterns": [
30-
"./packages/base/src/SearchBar/__tests__/common.tsx",
31-
"<rootDir>/node_modules",
32-
"<rootDir>/website",
33-
"<rootDir>/dist"
34-
],
35-
"coveragePathIgnorePatterns": [
36-
"./packages/base/src/searchbar/__tests__/common.tsx"
37-
],
38-
"collectCoverageFrom": [
39-
"packages/base/src/**/*.tsx",
40-
"!packages/base/src/index.tsx",
41-
"!packages/base/src/helpers/*.tsx"
42-
],
43-
"collectCoverage": true,
44-
"globals": {
45-
"__DEV__": true
46-
},
47-
"setupFilesAfterEnv": [
48-
"<rootDir>/packages/base/.ci/setupTests.ts"
49-
],
50-
"testRegex": "/__tests__/.*\\.(ts|tsx|js)$",
51-
"transform": {
52-
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
53-
},
54-
"moduleFileExtensions": [
55-
"ts",
56-
"tsx",
57-
"js",
58-
"jsx",
59-
"json",
60-
"node"
61-
]
43+
"author": "Nader Dabit & Monte Thakkar",
44+
"license": "MIT",
45+
"bugs": {
46+
"url": "https://github.com/react-native-elements/react-native-elements/issues"
47+
},
48+
"homepage": "https://reactnativeelements.com/",
49+
"collective": {
50+
"type": "opencollective",
51+
"url": "https://opencollective.com/react-native-elements",
52+
"logo": "https://opencollective.com/react-native-elements/logo.txt"
6253
},
6354
"lint-staged": {
6455
"packages/**/*.{ts,tsx}": [
6556
"eslint --fix",
66-
"bash -c tsc --noEmit true",
57+
"prettier --write",
58+
"tsc --noEmit --composite false",
6759
"jest --bail --findRelatedTests"
6860
],
6961
"packages/**/*.{js,jsx}": [
7062
"eslint --fix",
63+
"prettier --write",
7164
"jest --bail --findRelatedTests"
7265
],
7366
"**/*.md": [
@@ -77,10 +70,5 @@
7770
"repository": {
7871
"type": "git",
7972
"url": "git+https://github.com/react-native-elements/react-native-elements.git"
80-
},
81-
"husky": {
82-
"hooks": {
83-
"pre-commit": "lint-staged"
84-
}
8573
}
8674
}

packages/base/.ci/setupTests.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
jest.mock(
2-
'../node_modules/react-native/Libraries/LayoutAnimation/LayoutAnimation.js'
2+
'../../../node_modules/react-native/Libraries/LayoutAnimation/LayoutAnimation.js'
33
);
44
jest.mock(
5-
'../node_modules/react-native/Libraries/Animated/src/NativeAnimatedHelper'
5+
'../../../node_modules/react-native/Libraries/Animated/NativeAnimatedHelper.js'
66
);

packages/base/.ci/testHelper.tsx

+2-13
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ import {
66
fireEvent,
77
act,
88
} from '@testing-library/react-native';
9-
import { ThemeProvider, FullTheme, colors } from '../src/config';
10-
import deepmerge from 'deepmerge';
119

1210
export { fireEvent, act };
1311

1412
// for getting findByType e.g. wrapper.findByType(Icon) see implementation in Avatar Component
1513
export const renderWithWrapper = (
1614
children: React.ReactElement<any, string | JSXElementConstructor<any>>,
1715
wrapperTestID?: string,
18-
themeProp: Partial<FullTheme> = {},
16+
_themeProp: unknown = {},
1917
renderOptions?: RenderOptions
2018
) => {
2119
const options: RenderOptions = {
@@ -24,16 +22,7 @@ export const renderWithWrapper = (
2422
}),
2523
...renderOptions,
2624
};
27-
const renderApi = render(
28-
themeProp ? (
29-
<ThemeProvider theme={deepmerge({ colors }, themeProp)}>
30-
{children}
31-
</ThemeProvider>
32-
) : (
33-
children
34-
),
35-
options
36-
);
25+
const renderApi = render(children, options);
3726
const wrapper = renderApi.queryByTestId(wrapperTestID || 'wrapper');
3827
return { wrapper, ...renderApi };
3928
};

packages/base/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Checkout the official
9292
on Expo which uses all of the React Native Elements components.
9393

9494
If you are looking to contribute to the React Native Elements App, click
95-
[here](https://github.com/react-native-elements/react-native-elements/tree/example) to
95+
[here](https://github.com/react-native-elements/react-native-elements/tree/next/example) to
9696
view the implementation & run the RNE expo app locally.
9797

9898
## Documentation

packages/base/package.json

+4-38
Original file line numberDiff line numberDiff line change
@@ -50,47 +50,32 @@
5050
},
5151
"devDependencies": {
5252
"@react-native-community/eslint-config": "^2.0.0",
53-
"@testing-library/react-native": "^7.0.2",
5453
"@types/color": "^3.0.1",
5554
"@types/hoist-non-react-statics": "^3.3.1",
56-
"@types/jest": "^26.0.23",
5755
"@types/lodash.isequal": "^4.5.5",
58-
"@types/react-native": "*",
5956
"@types/react-test-renderer": "^17.0.0",
60-
"auto-changelog": "^2.2.1",
61-
"babel-jest": "^26.3.0",
62-
"child_process": "^1.0.2",
63-
"eslint": "^7.9.0",
64-
"husky": "^4.3.0",
65-
"jest": "^26.4.2",
66-
"jest-transform-stub": "^2.0.0",
67-
"lint-staged": "^10.4.0",
6857
"metro-react-native-babel-preset": "^0.63.0",
69-
"react": "16.13.1",
70-
"react-dom": "16.13.1",
71-
"react-native": "0.64.3",
7258
"react-native-safe-area-context": "^3.1.9",
7359
"react-native-vector-icons": "^7.0.0",
7460
"react-test-renderer": "^16.13.1",
75-
"rimraf": "^3.0.2",
76-
"ts-node": "^10.2.0",
77-
"typescript": "^4.3.5",
7861
"utility-types": "^3.10.0"
7962
},
8063
"peerDependencies": {
8164
"react-native-safe-area-context": "^3.1.9",
8265
"react-native-vector-icons": ">7.0.0"
8366
},
8467
"jest": {
68+
"displayName": "@react-native-elements/base",
8569
"preset": "react-native",
8670
"timers": "fake",
87-
"coverageDirectory": "./coverage/",
8871
"testPathIgnorePatterns": [
8972
"./src/SearchBar/__tests__/common.tsx",
9073
"<rootDir>/node_modules",
91-
"<rootDir>/website",
9274
"<rootDir>/dist"
9375
],
76+
"transformIgnorePatterns": [
77+
"<rootDir>/../../node_modules/(?!(@react-native|react-native)/)"
78+
],
9479
"coveragePathIgnorePatterns": [
9580
"./src/searchbar/__tests__/common.tsx"
9681
],
@@ -119,27 +104,8 @@
119104
"node"
120105
]
121106
},
122-
"lint-staged": {
123-
"src/**/*.{ts,tsx}": [
124-
"eslint --fix",
125-
"bash -c tsc",
126-
"jest --bail --findRelatedTests"
127-
],
128-
"src/**/*.{js,jsx}": [
129-
"eslint --fix",
130-
"jest --bail --findRelatedTests"
131-
],
132-
"**/*.md": [
133-
"prettier --single-quote --trailing-comma=es5 --write"
134-
]
135-
},
136107
"repository": {
137108
"type": "git",
138109
"url": "git+https://github.com/react-native-elements/react-native-elements.git"
139-
},
140-
"husky": {
141-
"hooks": {
142-
"pre-commit": "lint-staged"
143-
}
144110
}
145111
}

packages/themed/.ci/setupTests.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
jest.mock(
2+
'../../../node_modules/react-native/Libraries/LayoutAnimation/LayoutAnimation.js'
3+
);
4+
jest.mock(
5+
'../../../node_modules/react-native/Libraries/Animated/NativeAnimatedHelper.js'
6+
);

packages/themed/.ci/testHelper.tsx

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { JSXElementConstructor } from 'react';
2+
import { View } from 'react-native';
3+
import {
4+
render,
5+
RenderOptions,
6+
fireEvent,
7+
act,
8+
} from '@testing-library/react-native';
9+
import { ThemeProvider, FullTheme, colors } from '../src/config';
10+
import deepmerge from 'deepmerge';
11+
12+
export { fireEvent, act };
13+
14+
// for getting findByType e.g. wrapper.findByType(Icon) see implementation in Avatar Component
15+
export const renderWithWrapper = (
16+
children: React.ReactElement<any, string | JSXElementConstructor<any>>,
17+
wrapperTestID?: string,
18+
themeProp: Partial<FullTheme> = {},
19+
renderOptions?: RenderOptions
20+
) => {
21+
const options: RenderOptions = {
22+
...(!wrapperTestID && {
23+
wrapper: (props) => <View {...props} testID="wrapper" />,
24+
}),
25+
...renderOptions,
26+
};
27+
const renderApi = render(
28+
themeProp ? (
29+
<ThemeProvider theme={deepmerge({ colors }, themeProp)}>
30+
{children}
31+
</ThemeProvider>
32+
) : (
33+
children
34+
),
35+
options
36+
);
37+
const wrapper = renderApi.queryByTestId(wrapperTestID || 'wrapper');
38+
return { wrapper, ...renderApi };
39+
};

0 commit comments

Comments
 (0)