|
| 1 | +# Contributing |
| 2 | + |
| 3 | +We welcome code contributions, feature requests, and reporting of issues. Please |
| 4 | +see [guidelines and instructions](.github/CONTRIBUTING.md). |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +This repo is subdivided into 3 parts using pnpm workspaces: |
| 9 | + |
| 10 | +- The base repo (workspace name = `checkout-sheet-kit-react-native`) |
| 11 | +- The `@shopify/checkout-sheet-kit` Native Module (workspace name = `module`) |
| 12 | +- The sample application (workspace name = `sample`) |
| 13 | + |
| 14 | +Each of the workspaces contains a separate `package.json` to manage tasks |
| 15 | +specific to each workspace. |
| 16 | + |
| 17 | +## Getting started |
| 18 | + |
| 19 | +If you've cloned the repo and want to run the sample app, you will first need to: |
| 20 | + |
| 21 | +1. Install the NPM dependencies |
| 22 | + |
| 23 | + ```sh |
| 24 | + pnpm install |
| 25 | + ``` |
| 26 | + |
| 27 | +2. Install iOS dependencies. (N.b. Android dependencies are automatically installed by Gradle) |
| 28 | + |
| 29 | + ```sh |
| 30 | + pnpm pod-install sample/ios |
| 31 | + ``` |
| 32 | + |
| 33 | +3. Build the Native Module |
| 34 | + |
| 35 | + ```sh |
| 36 | + pnpm module build |
| 37 | + ``` |
| 38 | + |
| 39 | +4. Start the Metro server |
| 40 | + |
| 41 | + ```sh |
| 42 | + pnpm sample start |
| 43 | + ``` |
| 44 | + |
| 45 | +5. Run the sample application (in a new terminal / tab) |
| 46 | + |
| 47 | + ```sh |
| 48 | + pnpm sample ios |
| 49 | + # or |
| 50 | + pnpm sample android |
| 51 | + ``` |
| 52 | + |
| 53 | +## Optional: Speed up builds with sccache |
| 54 | + |
| 55 | +For faster native compilation (especially on incremental builds), you can install [sccache](https://github.com/mozilla/sccache), a shared compilation cache: |
| 56 | + |
| 57 | +```sh |
| 58 | +# macOS (using Homebrew) |
| 59 | +brew install sccache |
| 60 | + |
| 61 | +# Ubuntu/Debian |
| 62 | +cargo install sccache |
| 63 | + |
| 64 | +# Other systems: see https://github.com/mozilla/sccache#installation |
| 65 | +``` |
| 66 | + |
| 67 | +The build scripts will automatically detect and use sccache if available. On Android, React Native's CMake files look for a command named `ccache`, so the sample Android scripts put an sccache-backed compatibility command first on `PATH`. If you encounter any build issues, you can temporarily disable it: |
| 68 | + |
| 69 | +```sh |
| 70 | +# Disable sccache for a single build |
| 71 | +SCCACHE=false pnpm sample ios |
| 72 | +SCCACHE=false pnpm sample android |
| 73 | +``` |
| 74 | + |
| 75 | +## Making changes to the Native Module |
| 76 | + |
| 77 | +If your intentions are to modify the TS code for the Native Module under |
| 78 | +`modules/@shopify/checkout-sheet-kit`, note that you will not need to rebuild to |
| 79 | +observe your changes in the sample app. This is because the sample app is |
| 80 | +importing the TS files directly from the module directory (through symlinking). |
| 81 | + |
| 82 | +However, if you're running the iOS/Android tests against the module, you will |
| 83 | +first need to run `pnpm module build` each time you change the TS code. |
| 84 | + |
| 85 | +## Cleaning the workspaces |
| 86 | + |
| 87 | +There are a handful of commands to clean the individual workspaces. |
| 88 | + |
| 89 | +```sh |
| 90 | +# Clear the current directory from watchman |
| 91 | +pnpm clean |
| 92 | + |
| 93 | +# Removes the "sample/node_modules" directory |
| 94 | +# Removes "ios/pods" directory |
| 95 | +# Removes "ios/build" directory |
| 96 | +pnpm sample clean |
| 97 | + |
| 98 | +# Removes the "lib" directory for the Native Module |
| 99 | +pnpm module clean |
| 100 | +``` |
| 101 | + |
| 102 | +## Linting the code |
| 103 | + |
| 104 | +Linting the codespaces will (1) compile the code with TypeScript and (2) run |
| 105 | +eslint over the source code. |
| 106 | + |
| 107 | +```sh |
| 108 | +# Lint the Native Module TS code |
| 109 | +pnpm module lint |
| 110 | + |
| 111 | +# Lint the Sample App TS code |
| 112 | +pnpm sample lint |
| 113 | +``` |
| 114 | + |
| 115 | +## Testing |
| 116 | + |
| 117 | +There are 3 types of tests in this repo: Typescript, Swift and Java - each for |
| 118 | +testing the Native Module. |
| 119 | + |
| 120 | +```sh |
| 121 | +# Run Jest tests for "modules/@shopify/checkout-sheet-kit/src/**/*.tsx" |
| 122 | +pnpm test |
| 123 | + |
| 124 | +# Run swift tests for the Native Module |
| 125 | +pnpm sample test:ios |
| 126 | + |
| 127 | +# Run Java tests for the Native Module |
| 128 | +pnpm sample test:android |
| 129 | +``` |
| 130 | + |
| 131 | +## Running the sample app |
| 132 | + |
| 133 | +To run the sample app in this repo, first clone the repo and run the following |
| 134 | +commands at the root of the project directory. |
| 135 | + |
| 136 | +### Install NPM dependencies |
| 137 | + |
| 138 | +```sh |
| 139 | +pnpm install |
| 140 | +``` |
| 141 | + |
| 142 | +### Install Cocoapods |
| 143 | + |
| 144 | +```sh |
| 145 | +pnpm pod-install sample/ios |
| 146 | +``` |
| 147 | + |
| 148 | +### Build the local module |
| 149 | + |
| 150 | +```sh |
| 151 | +pnpm module build |
| 152 | +``` |
| 153 | + |
| 154 | +### Update the dotenv file |
| 155 | + |
| 156 | +Replace the details in the `sample/.env.example` file and rename it to |
| 157 | +`sample/.env` |
| 158 | + |
| 159 | +``` |
| 160 | +# Storefront Details |
| 161 | +STOREFRONT_DOMAIN="YOUR_STORE.myshopify.com" |
| 162 | +STOREFRONT_ACCESS_TOKEN="YOUR_PUBLIC_STOREFRONT_ACCESS_TOKEN" |
| 163 | +STOREFRONT_VERSION="2025-07" |
| 164 | +``` |
| 165 | + |
| 166 | +### Start the sample app |
| 167 | + |
| 168 | +```sh |
| 169 | +pnpm sample start |
| 170 | +``` |
0 commit comments