|
3 | 3 | This repo is subdivided into 3 parts using yarn workspaces: |
4 | 4 |
|
5 | 5 | - The base repo (workspace name = `checkout-kit-react-native`) |
6 | | -- The `react-native-shopify-checkout-kit` Native Module (workspace name = `module`) |
| 6 | +- The `react-native-shopify-checkout-kit` Native Module (workspace name = |
| 7 | + `module`) |
7 | 8 | - The sample application (workspace name = `sample`) |
8 | 9 |
|
9 | | -Each of the worksapces contains a separate `package.json` to manage tasks specific to each workspace. |
| 10 | +Each of the worksapces contains a separate `package.json` to manage tasks |
| 11 | +specific to each workspace. |
10 | 12 |
|
11 | | -## Base repo |
| 13 | +## Getting started |
12 | 14 |
|
13 | | -## Install dependencies |
| 15 | +If you've cloned the repo and want to run the sample app, you will first need |
| 16 | +to: |
14 | 17 |
|
15 | | -Run `yarn` to install the dependencies for all workspaces in the repo. |
| 18 | +1. Install the NPM dependencies |
| 19 | +2. Install iOS dependencies (cocoapods) |
| 20 | +3. Build the Native Module |
16 | 21 |
|
17 | | ---- |
18 | | - |
19 | | -## `react-native-shopify-checkout-kit` Module |
| 22 | +```sh |
| 23 | +# Install NPM dependencies and link local module |
| 24 | +yarn |
20 | 25 |
|
21 | | -### Clean the modules folder |
| 26 | +# Install Cocoapods for iOS |
| 27 | +yarn pod-install sample/ios |
| 28 | +# Note: Android dependencies are automatically installed by Gradle |
22 | 29 |
|
23 | | -```bash |
24 | | -yarn module clean |
| 30 | +# Build the Native Module JS |
| 31 | +yarn module build |
25 | 32 | ``` |
26 | 33 |
|
27 | | -### Build the `react-native-shopify-checkout-kit` module |
| 34 | +If all of these steps have succeeded, you can now run the sample app with: |
28 | 35 |
|
29 | 36 | ```sh |
30 | | -yarn module build |
| 37 | +yarn sample start |
31 | 38 | ``` |
32 | 39 |
|
33 | | -### Lint the module |
| 40 | +This command will start the Metro server. Follow the steps given by Metro to |
| 41 | +open both the iOS and Android simulators/emulators respectively. |
34 | 42 |
|
35 | | -```sh |
36 | | -yarn module lint |
37 | | -``` |
| 43 | +## Making changes to the Native Module |
38 | 44 |
|
39 | | ---- |
| 45 | +If your intentions are to modify the TS code for the Native Module under |
| 46 | +`modules/react-native-shopify-checkout-kit`, note that you will not need to |
| 47 | +rebuild to observe your changes in the sample app. This is because the sample |
| 48 | +app is importing the TS files directly from the module directory (through |
| 49 | +symlinking). |
40 | 50 |
|
41 | | -## Sample application |
| 51 | +However, if you're running the iOS/Android tests against the module, you will |
| 52 | +first need to run `yarn module build` each time you change the TS code. |
42 | 53 |
|
43 | | -## Start the sample application |
| 54 | +## Cleaning the workspaces |
44 | 55 |
|
45 | | -### For Android |
| 56 | +There are a handful of commands to clean the individual workspaces. |
46 | 57 |
|
47 | | -```bash |
48 | | -# Start the Metro server |
49 | | -yarn sample start |
| 58 | +```sh |
| 59 | +# Clear the current directory from watchman |
| 60 | +yarn clean |
50 | 61 |
|
51 | | -# Start the Metro server and run the Android sample application |
52 | | -yarn sample android |
| 62 | +# Removes the "sample/node_modules" directory |
| 63 | +# Removes "ios/pods" directory |
| 64 | +# Removes "ios/build" directory |
| 65 | +yarn sample clean |
53 | 66 |
|
54 | | -# Start the Metro server and run the iOS sample application |
55 | | -yarn sample android |
| 67 | +# Removes the "lib" directory for the Native Module |
| 68 | +yarn module clean |
56 | 69 | ``` |
57 | 70 |
|
58 | | -If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. |
59 | | - |
60 | | -This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. |
| 71 | +## Linting the code |
61 | 72 |
|
62 | | -## Lint the sample application |
| 73 | +Linting the codespaces will (1) compile the code with TypeScript and (2) run |
| 74 | +eslint over the source code. |
63 | 75 |
|
64 | 76 | ```sh |
| 77 | +# Lint the Native Module TS code |
| 78 | +yarn module lint |
| 79 | + |
| 80 | +# Lint the Sample App TS code |
65 | 81 | yarn sample lint |
66 | 82 | ``` |
| 83 | + |
| 84 | +## Testing |
| 85 | + |
| 86 | +There are 3 types of tests in this repo: Typescript, Swift and Java - each for |
| 87 | +testing the Native Module. |
| 88 | + |
| 89 | +```sh |
| 90 | +# Run Jest tests for "modules/react-native-shopify-checkout-kit/src/**/*.tsx" |
| 91 | +yarn test |
| 92 | + |
| 93 | +# Run swift tests for the Native Module |
| 94 | +yarn sample test:ios |
| 95 | + |
| 96 | +# Run Java tests for the Native Module |
| 97 | +yarn sample test:android |
| 98 | +``` |
0 commit comments