You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-43Lines changed: 15 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,6 @@
5
5
This Example Storefront is to serve as a reference on how to implement a web based storefront using the Reaction Commerce GraphQL API. You can fork this project as a jumping off point or create your own custom experience using your prefered client-side technology. While we believe our example storefront is full featured enough to use in production, it may be missing features your shop requires at this time.
6
6
7
7
## Features
8
-
9
8
Reaction comes with a robust set of core commerce capabilities right out of the box. And since anything in our codebase can be extended, overwritten, or installed as a package, you may also customize anything on our platform.
10
9
11
10
Check out the full list of Reaction [features](https://www.reactioncommerce.com/features) and [release history](https://reactioncommerce.com/roadmap) for more info.
@@ -26,11 +25,12 @@ This example storefront is built with [Next.js](https://nextjs.org/), [React](ht
26
25
Follow the [Reaction Platform docs](https://docs.reactioncommerce.com/docs/installation-reaction-platform) to install and run all the services necessary to run the storefront:
**Note**: The storefront has redirects so that if you open [http://localhost:4000/graphql](http://localhost:4000/graphql), you'll be redirected to the GraphQL Playground.
@@ -51,37 +51,32 @@ When running the storefront and Reaction for the first time, you will need to co
51
51
Read the docs for [setting up Segment or a custom analytics tracker](docs/tracking-events.md)
52
52
53
53
## Documentation
54
-
55
54
-[Example Storefront full documentation](./docs)
56
55
-[Example Storefront Component Library repository](https://github.com/reactioncommerce/reaction-component-library), [documentation](https://github.com/reactioncommerce/reaction-component-library/tree/master/docs), and [component documentation](http://designsystem.reactioncommerce.com/)
57
56
-[Reaction Docs: Using GraphQL](https://docs.reactioncommerce.com/docs/graphql-using)
58
57
-[Reaction Docs: Testing with Jest](https://docs.reactioncommerce.com/docs/testing-reaction)
59
-
-[Reaction Docs: Developing with Docker](https://docs.reactioncommerce.com/docs/installation-docker-development)
58
+
-[Reaction Docs: Developing with Docker](https://docs.reactioncommerce.com/docs/installation-docker-development
59
+
)
60
60
61
61
## Development
62
62
63
63
The Reaction Platform runs the storefront with Docker, so you will have to use Docker commands to view logs, run commands inside the container and more. To run commands specifically for the storefront, make sure to change directories into the `example-storefront` directory within the `reaction-platform` repository:
64
-
65
64
```sh
66
65
cd example-storefront
67
66
```
68
67
69
68
### Build and run in development mode with logs
70
-
71
69
Create a symbolic link to use the development Docker image:
If running for the first time or environment variables in `.env.example` have changed execute the command below to update environment variables.
78
-
79
75
```
80
76
./bin/setup
81
77
```
82
78
83
79
Start the storefront by executing:
84
-
85
80
```sh
86
81
docker-compose up -d && docker-compose logs -f
87
82
```
@@ -99,31 +94,26 @@ docker-compose run --rm --service-ports web yarn start
99
94
```sh
100
95
docker-compose run --rm web [command]
101
96
```
102
-
103
97
Run any command inside a Docker container and then remove the container. Use this to run any tooling operations. Remember your project directory will be mounted and things will usually just work. See Yarn section below for more examples.
104
98
105
99
### Run tests in container
106
100
107
101
Run tests locally
108
-
109
102
```sh
110
103
docker-compose run --rm web yarn test
111
104
```
112
105
113
106
Run tests locally without cache (this can be helpful if changes aren't showing up)
114
-
115
107
```sh
116
108
docker-compose run --rm web yarn test --no-cache
117
109
```
118
110
119
111
To run Snyk security tests (this will run tests in the same way as CI)
120
-
121
112
```sh
122
113
docker-compose run --rm web sh -c "cp package.json ../ && cp .snyk ../ && cd .. && snyk auth && snyk test"
123
114
```
124
115
125
116
To run ESLint
126
-
127
117
```sh
128
118
docker-compose run --rm web eslint src
129
119
```
@@ -139,15 +129,13 @@ You can use the Google Chrome DevTools to debug the code running in the Node.js
139
129
140
130
Yarn & NPM should run inside the Docker container. We've taken steps to ensure that the node_modules are placed into a cacheable location. If you run Yarn locally, the node_modules are written directly to the project directory and take precedence over those from the Docker build.
141
131
**Yarn Add**
142
-
143
132
```
144
133
docker-compose run --rm web yarn add --dev [package]
145
134
```
146
135
147
136
**Yarn Install**
148
137
149
138
⚠️ Always rebuild the image and start a new container after modifying yarn.lock or Dockerfile!
150
-
151
139
```
152
140
docker-compose run --rm web yarn install
153
141
docker-compose down --rmi local
@@ -167,29 +155,25 @@ Sometimes we need to test the [Example Storefront Component Library](https://git
167
155
1. Inside your `.env` file, change `INTERNAL_GRAPHQL_URL` to equal `http://localhost:3000/graphql`, the same as the `EXTERNAL_GRAPHQL_URL`
168
156
1. Start the storefront locally by running the command `export $(cat .env | xargs) && yarn dev`
169
157
1. Your storefront should now be running at `localhost:4000`
170
-
- If you see errors about not being able to find peer dependency packages, that seems to be an issues with yarn linking. You can just temporarily `yarn add` each of those packages in the component library `package/dist` folder. (This folder is gitignored anyway.)
158
+
- If you see errors about not being able to find peer dependency packages, that seems to be an issues with yarn linking. You can just temporarily `yarn add` each of those packages in the component library `package/dist` folder. (This folder is gitignored anyway.)
171
159
1. After your changes are tested, shut down the storefront by running the command `CTRL+C`
172
160
1. Run `yarn unlink "@reactioncommerce/components"` in the storefront repo folder
173
161
1.`cd` to the `package/dist` folder of the `reaction-component-library` repo. Run the command `yarn unlink` to unlink the local version of the component library
174
162
1. Undo the renaming of your `.yarnrc` file
175
163
1. Undo the URL change inside your `.env` file
176
164
177
165
## Clean up containers
178
-
179
166
Stop, and retain containers:
180
-
181
167
```sh
182
168
docker-compose stop
183
169
```
184
170
185
171
Stop, and remove containers:
186
-
187
172
```sh
188
173
docker-compose down
189
174
```
190
175
191
176
Stop, and remove containers, volumes and built images:
192
-
193
177
```sh
194
178
docker-compose down -v --rmi local
195
179
```
@@ -203,7 +187,6 @@ Run this command to build a Docker image with the production build of the app in
Where X.X.X indicates the tag version you want to use, i.e. `3.1.0`
208
191
209
192
Then, to start the app on your machine, make sure the Reaction API container is already running and enter:
@@ -231,37 +214,28 @@ Want to request a feature? Use our [Reaction Feature Requests repository](https:
231
214
We love your pull requests! Check our our [`Good First Issue`](https://github.com/reactioncommerce/example-storefront/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) and [`Help Wanted`](https://github.com/reactioncommerce/example-storefront/issues?q=label%3A%22help+wanted%22) tags for good issues to tackle.
232
215
233
216
### Pull Request guidelines
234
-
235
217
Pull requests should pass all automated tests, style, and security checks.
236
218
237
219
#### Automated Tests
238
-
239
220
Your code should pass all [acceptance tests and unit tests](https://docs.reactioncommerce.com/reaction-docs/trunk/testing-reaction). Run
240
-
241
221
```sh
242
222
docker-compose run --rm web yarn test
243
223
```
244
-
245
224
to run the test suites locally. If you're adding functionality to Reaction, you should add tests for the added functionality. You can run the tests locally without cache if necessary by passing the `--no-cache` flag. This can be helpful if changes aren't showing up.
246
-
247
225
```sh
248
226
docker-compose run --rm web yarn test --no-cache
249
227
```
250
228
251
229
To update a failing snapshot (if you've made changes to a component)
252
-
253
230
```sh
254
231
docker-compose run --rm web yarn test -u
255
232
```
256
233
257
234
#### Eslint
258
-
259
235
We require that all code contributed to Reaction follows [Reaction's ESLint rules](https://github.com/reactioncommerce/reaction-eslint-config). You can run
260
-
261
236
```
262
237
docker-compose run --rm web eslint src
263
238
```
264
-
265
239
to run ESLint against your code locally.
266
240
267
241
Please follow the [Reaction Code Style Guide](https://docs.reactioncommerce.com/docs/styleguide). Check out our guides to [JSDoc](https://docs.reactioncommerce.com/docs/jsdoc-style-guide), [Git](https://docs.reactioncommerce.com/docs/git-style-guide), [error handling](https://docs.reactioncommerce.com/docs/error-handling-guide), [logging](https://docs.reactioncommerce.com/docs/logging), and [React](https://docs.reactioncommerce.com/docs/react-best-practices).
@@ -271,9 +245,7 @@ We also request that you follow the our [pull request template](https://docs.rea
271
245
Get more details in our [Contributing Guide](https://docs.reactioncommerce.com/docs/contributing-to-reaction).
272
246
273
247
### Developer Certificate of Origin
274
-
275
248
We use the [Developer Certificate of Origin (DCO)](https://developercertificate.org/) in lieu of a Contributor License Agreement for all contributions to Reaction Commerce open source projects. We request that contributors agree to the terms of the DCO and indicate that agreement by signing all commits made to Reaction Commerce projects by adding a line with your name and email address to every Git commit message contributed:
0 commit comments