-
Notifications
You must be signed in to change notification settings - Fork 6
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
Re-org repo to prepare as a package #7
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
443a53e
Re-org repo to prepare as a package
markmur dff7f27
Huge amount of changes
markmur 34c4dd7
Set yarn version in CI
markmur 201a1f3
Add LICENSE, README and prepack script to module
markmur 646c2fb
Build the module in the CI
markmur 3b29463
Add reusable setup file
markmur a5f7eed
Fix iOS
markmur d829d8e
Fix eslint babel issue
markmur 4dd957e
Fix lint
markmur 4d516bc
Add .yarn/install-state.gz
markmur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
|
||
indent_style = space | ||
indent_size = 2 | ||
|
||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Setup | ||
description: Setup Node.js and install dependencies | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Cache dependencies | ||
id: yarn-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
**/node_modules | ||
.yarn/install-state.gz | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
${{ runner.os }}-yarn- | ||
|
||
- name: Install dependencies | ||
if: steps.yarn-cache.outputs.cache-hit != 'true' | ||
run: yarn install --immutable | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: CI Pipeline | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint-sample: | ||
name: Lint Sample App | ||
runs-on: shopify-ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- run: yarn sample lint | ||
|
||
lint-native-module: | ||
name: Lint Native Module | ||
runs-on: shopify-ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- run: yarn module lint | ||
|
||
lint-swift: | ||
name: Lint Swift code for Native Module | ||
runs-on: shopify-ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run SwiftLint | ||
uses: norio-nomura/action-swiftlint@3.2.1 | ||
with: | ||
args: --strict | ||
|
||
- name: Check License Headers | ||
run: ./scripts/copy_license && git diff --name-only --exit-code | ||
|
||
build-native-module: | ||
name: Build `react-native-shopify-checkout-kit` | ||
runs-on: shopify-ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- run: yarn module build |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
markmur marked this conversation as resolved.
Show resolved
Hide resolved
|
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
nmHoistingLimits: workspaces | ||
|
||
nodeLinker: node-modules | ||
|
||
plugins: | ||
- path: scripts/pod-install.cjs | ||
|
||
yarnPath: .yarn/releases/yarn-4.0.2.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Contributing | ||
|
||
This repo is subdivided into 3 parts using yarn workspaces: | ||
|
||
- The base repo (workspace name = `checkout-kit-react-native`) | ||
- The `react-native-shopify-checkout-kit` Native Module (workspace name = `module`) | ||
- The sample application (workspace name = `sample`) | ||
|
||
Each of the worksapces contains a separate `package.json` to manage tasks specific to each workspace. | ||
|
||
## Base repo | ||
|
||
## Install dependencies | ||
|
||
Run `yarn` to install the dependencies for all workspaces in the repo. | ||
|
||
--- | ||
|
||
## `react-native-shopify-checkout-kit` Module | ||
|
||
### Clean the modules folder | ||
|
||
```bash | ||
yarn module clean | ||
``` | ||
|
||
### Build the `react-native-shopify-checkout-kit` module | ||
|
||
```sh | ||
yarn module build | ||
``` | ||
|
||
### Lint the module | ||
|
||
```sh | ||
yarn module lint | ||
``` | ||
|
||
--- | ||
|
||
## Sample application | ||
|
||
## Start the sample application | ||
|
||
### For Android | ||
|
||
```bash | ||
# Start the Metro server | ||
yarn sample start | ||
|
||
# Start the Metro server and run the Android sample application | ||
yarn sample android | ||
|
||
# Start the Metro server and run the iOS sample application | ||
yarn sample android | ||
``` | ||
|
||
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. | ||
|
||
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. | ||
|
||
## Lint the sample application | ||
|
||
```sh | ||
yarn sample lint | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,47 @@ | ||
# Checkout Kit - React Native | ||
|
||
![image](https://github.com/Shopify/checkout-kit-react-native/assets/318265/1f7b1b5b-0212-4ba9-93fa-14b76ae5d239) | ||
TODO | ||
|
||
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding. | ||
|
||
## Step 1: Start the Metro Server | ||
## Install | ||
|
||
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native. | ||
```sh | ||
yarn add react-native-shopify-checkout-kit | ||
|
||
To start Metro, run the following command from the _root_ of your React Native project: | ||
|
||
```bash | ||
# using npm | ||
npm start | ||
|
||
# OR using Yarn | ||
yarn start | ||
``` | ||
|
||
## Step 2: Start your Application | ||
|
||
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app: | ||
|
||
### For Android | ||
|
||
```bash | ||
# using npm | ||
npm run android | ||
|
||
# OR using Yarn | ||
yarn android | ||
# or using npm | ||
npm install react-native-shopify-checkout-kit | ||
``` | ||
|
||
### For iOS | ||
|
||
```bash | ||
# using npm | ||
npm run ios | ||
|
||
# OR using Yarn | ||
yarn ios | ||
## Usage | ||
|
||
```tsx | ||
import {ShopifyCheckout} from "react-native-shopify-checkout-kit" | ||
|
||
function App() { | ||
const checkoutURL = useRef<string>(null) | ||
|
||
const handleAddToCart = useCallback((variantId) => { | ||
// Add item to cart using the Storefront API | ||
// Retrieve checkoutUrl from the Storefront response | ||
checkoutURL.current = response.data.cartLinesAdd.cart.checkoutUrl | ||
}, []); | ||
|
||
const handleCheckout = useCallback(() => { | ||
if (checkoutURL.current) { | ||
ShopifyCheckout.present(checkoutURL.current) | ||
} | ||
}, []) | ||
|
||
return ( | ||
<Catalog> | ||
<Product onAddToCart={handleAddToCart} /> | ||
<Button onPress={handleCheckout}> | ||
<Text>Checkout</Text> | ||
</Button> | ||
<Catalog> | ||
) | ||
} | ||
``` | ||
|
||
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. | ||
|
||
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. | ||
|
||
## Step 3: Modifying your App | ||
|
||
Now that you have successfully run the app, let's modify it. | ||
|
||
1. Open `App.tsx` in your text editor of choice and edit some lines. | ||
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes! | ||
|
||
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes! | ||
|
||
## Congratulations! :tada: | ||
|
||
You've successfully run and modified your React Native App. :partying_face: | ||
|
||
### Now what? | ||
|
||
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). | ||
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). | ||
|
||
# Troubleshooting | ||
|
||
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. | ||
|
||
# Learn More | ||
|
||
To learn more about React Native, take a look at the following resources: | ||
|
||
- [React Native Website](https://reactnative.dev) - learn more about React Native. | ||
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. | ||
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. | ||
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. | ||
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. | ||
See [Contributing](./CONTRIBUTING.md) for contribution guidance. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should hopefully help with our swiftlint woes