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: dotcom-rendering/README.md
+87-55Lines changed: 87 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,19 +28,45 @@ $ cd dotcom-rendering
28
28
29
29
### Install Node.js
30
30
31
-
To install and manage Node versions we recommend using a Node version manager such as [fnm](https://github.com/Schniz/fnm), [nvm](https://github.com/nvm-sh/nvm) or [asdf](https://asdf-vm.com/guide/getting-started.html).
31
+
To install and manage Node versions, we highly recommend installing a Node version manager such as [fnm](https://github.com/Schniz/fnm) (preferred), [nvm](https://github.com/nvm-sh/nvm) or [asdf](https://asdf-vm.com/guide/getting-started.html).
32
32
33
-
To install Node, follow the instructions for the version manager of your choice.
33
+
Ensure you're at the root directory of this project, then follow the instructions for your version manager to install Node.
34
34
35
-
Our preferred Node version manager is [fnm](https://github.com/Schniz/fnm).
35
+
For `fnm` this will be:
36
36
37
-
Once installed, check the running Node version, ignoring any 'v' prefix, matches the version in [.nvmrc](../.nvmrc)
37
+
```
38
+
$ fnm use
39
+
```
40
+
41
+
For `nvm` this will be:
42
+
43
+
```
44
+
$ nvm use
45
+
```
46
+
47
+
Once installed, check the running Node version (ignoring any 'v' prefix) matches the version in [.nvmrc](../.nvmrc)
38
48
39
49
```
40
50
$ node --version
41
51
```
42
52
43
-
#### corepack
53
+
#### fnm
54
+
55
+
[fnm](https://github.com/Schniz/fnm) has some useful features which we recommend to make Node version detection as seamless as possible:
56
+
57
+
##### --use-on-cd
58
+
59
+
This configuration automatically detects and changes to the required Node version when changing directories.
You can view the JSON representation of an article as sent by [Frontend](https://github.com/guardian/frontend) to DCR, by appending `.json?dcr=true` to the production URL, for example:
If you're new to TypeScript projects, if you're trying to integrate with other applications or if you prefer to take things slow, we also have a more [detailed setup guide](docs/contributing/detailed-setup-guide.md).
113
+
If you're trying to integrate with other applications, we also have a more [detailed setup guide](docs/contributing/detailed-setup-guide.md).
114
+
115
+
## VS Code
116
+
117
+
We recommend using [VSCode](https://code.visualstudio.com/).
118
+
119
+
### Settings
120
+
121
+
We have configured a collection of _required_ VS Code settings in the file `.vscode/settings.json.required`.
122
+
123
+
We have configured a collection of _recommended_ VS Code settings in the file `.vscode/settings.json.recommended`.
124
+
125
+
Copy the required settings and any recommended settings you wish to use over to `.vscode/settings.json` to activate them.
126
+
127
+
The `settings.json` file is git ignored to prevent it from overriding any indivdiual developer's settings.
128
+
129
+
### Extensions
130
+
131
+
VSCode should prompt you to install our recommended extensions when you open the project.
132
+
133
+
You can also find these extensions by searching for `@recommended` in the extensions pane.
134
+
135
+
### Auto fix on save
136
+
137
+
We recommend you update your workspace settings to automatically fix formatting and linting errors on save, this avoids code style validation failures. These instructions assume you have installed the `esbenp.prettier-vscode` VSCode plugin:
138
+
139
+
1. Open the Command Palette (`shift + cmd + P`) and select:
| <img alt="Typescript" src="./docs/images/logo-typescript.png" width="350" /> | DCR is written in [TypeScript](https://www.typescriptlang.org/) |
99
157
| <img alt="Preact" src="./docs/images/logo-preact.jpg" width="350" /> | DCR is rendered on the server with Preact and uses Preact as the Client-side framework. We use preact-compat to ensure compatability with React modules. |
100
-
| <imgalt="Emotion CSS-in-JS"src="./docs/images/logo-emotion.png"width="350" /> | Emotion is css-in-js library, DCR uses the `css` tagged template literal style to allow CSS copy-pasting. |
101
-
| <imgalt="Typescript"src="./docs/images/logo-typescript.png"width="350" /> | DCR is written in Typescript. You can see the [block element types](./src/lib/content.d.ts) as an example of our Typescript types. |
102
-
| <imgalt="Express"src="./docs/images/logo-express.png"width="350" /> | We use Express as a very thin server to communicate with the Frontend endpoint. |
103
-
| <imgalt="Storybook"src="./docs/images/logo-storybook.jpg"width="350" /> | We use [storybook to generate component variations and 'layouts'](https://main--63e251470cfbe61776b0ef19.chromatic.com) that are then visual regression tested in Chromatic. You'll notice `.stories.` files in the repo for components that define the variations of components as defined by the component props. |
104
-
| <imgalt="Chromatic"src="./docs/images/logo-chromatic.jpg"width="350" /> | Chromatic is a visual regression testing tool that reviews our Storybook components at PR time. |
105
-
| <imgalt="Jest"src="./docs/images/logo-jest.jpg"width="350" /> | Jest is a unit testing tool. You will find Jest tests in the repo with `.test.` filenames. |
106
-
| <imgalt="Playwright"src="./docs/images/logo-playwright.svg"width="350" /> | Playwright is an integration testing tool that runs tests in the browser. You will find the Playwright tests in the [playwright directory](./playwright). |
158
+
| <img alt="Emotion CSS-in-JS" src="./docs/images/logo-emotion.png" width="350" /> | [Emotion](https://emotion.sh) is css-in-js library, DCR uses the `css` tagged template literal style to allow CSS copy-pasting. |
159
+
| <img alt="Express" src="./docs/images/logo-express.png" width="350" /> | We use [Express](https://expressjs.com/) as a very thin server to communicate with the Frontend endpoint. |
160
+
| <img alt="Storybook" src="./docs/images/logo-storybook.jpg" width="350" /> | We use [Storybook](https://storybook.js.org/) to generate [component variations](https://main--63e251470cfbe61776b0ef19.chromatic.com) that are then visual regression tested in [Chromatic](https://www.chromatic.com/). You'll notice `.stories.` files in the repository that define the component variations. |
161
+
| <img alt="Chromatic" src="./docs/images/logo-chromatic.jpg" width="350" /> | [Chromatic](https://www.chromatic.com/) is a visual regression testing tool that tests our Storybook components at PR time. |
162
+
| <img alt="Jest" src="./docs/images/logo-jest.jpg" width="350" /> | [Jest](https://jestjs.io) is a unit testing tool. You will find Jest tests in the repo with `.test.` filenames. |
163
+
| <img alt="Playwright" src="./docs/images/logo-playwright.svg" width="350" /> | [Playwright](https://playwright.dev/) is an integration testing tool that runs tests in the browser. You will find the Playwright tests in the [playwright directory](./playwright). |
107
164
| <img alt="AB Testing" src="./docs/images/logo-ab-testing.png" width="350" /> | The [A/B Testing library](https://github.com/guardian/csnx/tree/main/libs/@guardian/ab-core) is an internal NPM Module. There are [docs here](./docs/development/ab-testing-in-dcr.md). |
108
165
| <img alt="Deno" title="Deno logo, MIT License: https://deno.land/artwork" src="./docs/images/logo-deno.svg" width="350" /> | [Deno](https://deno.land/) is a JavaScript runtime that we've started incorporating into some of our Github Actions workflows. You will only need to install it if you are planning to run the workflow scripts locally. Some installation and troubleshooting instructions can be found in the [Deno scripts folder](../scripts/deno/README.md). |
109
166
110
-
## Design System
111
-
112
-
[Source](https://theguardian.design) is the Guardian's design system. For detailed and up-to-date information on how to use it, see the [Source guide](https://github.com/guardian/csnx/blob/main/docs/source/README.md).
113
-
114
167
## Concepts
115
168
116
169
There are some concepts to learn, that will make working with Dotcom Rendering clearer:
@@ -122,7 +175,11 @@ There are some concepts to learn, that will make working with Dotcom Rendering c
122
175
- [Enhancers](docs/patterns/enhancers.md)
123
176
- Data generated in Frontend
124
177
125
-
## Code Quality
178
+
## Design system
179
+
180
+
[Source](https://theguardian.design) is the Guardian's design system. For detailed and up-to-date information on how to use it, see the [Source guide](https://github.com/guardian/csnx/blob/main/docs/source/README.md).
181
+
182
+
## Code quality
126
183
127
184
You can ensure your code passes code quality tests by running:
128
185
@@ -149,7 +206,9 @@ $ make fix
149
206
150
207
See [the makefile](./makefile) for the full list.
151
208
152
-
[Read about testing tools and testing strategy](docs/testing.md).
209
+
## Testing
210
+
211
+
[Testing tools and testing strategy](docs/testing.md)
153
212
154
213
## Debugging
155
214
@@ -168,30 +227,3 @@ To check for vulnerabilities in development, you can run:
168
227
```sh
169
228
$ make audit
170
229
```
171
-
172
-
## IDE
173
-
174
-
We recommend using [VSCode](https://code.visualstudio.com/).
175
-
176
-
### Extensions
177
-
178
-
VSCode should prompt you to install our recommended extensions when you open the project.
179
-
180
-
You can also find these extensions by searching for `@recommended` in the extensions pane.
181
-
182
-
### Auto fix on save
183
-
184
-
We recommend you update your workspace settings to automatically fix formatting and linting errors on save, this avoids code style validation failures. These instructions assume you have installed the `esbenp.prettier-vscode` VSCode plugin:
185
-
186
-
1. Open the Command Palette (`shift + cmd + P`) and select:
0 commit comments