Skip to content

Commit 3196a4d

Browse files
committed
Update MonorepoNX-cheatshet.md
1 parent 4eb7933 commit 3196a4d

File tree

1 file changed

+49
-25
lines changed

1 file changed

+49
-25
lines changed

MonorepoNX-cheatsheet.md

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
# MapComponents Monorepo
22

3-
## Sync `package.json` Files with Syncpack
4-
5-
Keep your dependencies consistent across your monorepo using [Syncpack](https://github.com/JamieMason/syncpack):
6-
7-
### List Mismatched Dependency Versions
3+
## Install requirements
84

95
```bash
10-
npx syncpack list-mismatches
6+
npm i -g nx pnpm
117
```
128

13-
### Automatically Fix Mismatched Versions
9+
## Install dependencies
1410

1511
```bash
16-
npx syncpack fix-mismatches
12+
pnpm install
1713
```
1814

19-
## Use Depcheck to Find Unused Dependencies
15+
## Run Tasks
2016

21-
Go to your package directory and run:
17+
To see all projects maintained in this monorepo run:
2218

23-
```sh
24-
npx depcheck --skip-missing
19+
```bash
20+
nx show projects
2521
```
2622

27-
## Run Tasks
28-
2923
To see all available targets to run for a project, run:
3024

3125
```sh
32-
npx nx show project {package-name}
26+
nx show project {package-name}
3327
```
3428

3529
To run any task from any package, run:
3630

3731
```sh
38-
npx nx run {package-name}:{task-name}
32+
nx run {package-name}:{task-name}
33+
```
34+
35+
E.g. to start the dev environment of the react-maplibre project run:
36+
37+
```sh
38+
nx run react-maplibre:dev
3939
```
4040

4141
Alternatively, you can also use:
4242

4343
```sh
44-
npx nx {task-name} {package-name}
44+
nx {task-name} {package-name}
4545
```
4646

4747
To run all tasks in parallel, use:
4848

4949
```sh
50-
npx nx run-many --target={task-name} --all
50+
nx run-many --target={task-name} --all
5151
```
5252

5353
## Add New Projects
@@ -56,13 +56,13 @@ To run all tasks in parallel, use:
5656
To generate a new application, use:
5757

5858
```sh
59-
npx nx g @nx/react:application --directory=apps/my-app --name=my-app --no-interactive --e2eTestRunner=none
59+
nx g @nx/react:application --directory=apps/my-app --name=my-app --no-interactive --e2eTestRunner=none
6060
```
6161

6262
To generate a new library, use:
6363

6464
```sh
65-
npx nx g @nx/react:library --directory=packages/my-package --bundler=vite --name=my-package --importPath=@mapcomponents/my-package --no-interactive
65+
nx g @nx/react:library --directory=packages/my-package --bundler=vite --name=my-package --importPath=@mapcomponents/my-package --no-interactive
6666
```
6767

6868
Alternatively, [install Nx Console](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) to use the generator form.
@@ -120,7 +120,7 @@ Example:
120120
## Add Storybook to an existing project
121121

122122
```sh
123-
npx nx g @nx/react:storybook-configuration --project=my-package --generateStories=false --interactionTests=false --no-interactive
123+
nx g @nx/react:storybook-configuration --project=my-package --generateStories=false --interactionTests=false --no-interactive
124124
```
125125

126126
## Storybook Composition: How to Use It
@@ -186,13 +186,13 @@ You need to statically set a different port for each project in the `project.jso
186186
This is the command to run all the Storybooks in composition mode locally and in parallel:
187187

188188
```shell
189-
npx nx run storybook-composition:storybook-composition
189+
nx run storybook-composition:storybook-composition
190190
```
191191

192192
Then, in a new terminal, run:
193193

194194
```shell
195-
npx nx run storybook-composition:storybook
195+
nx run storybook-composition:storybook
196196
```
197197

198198
If a new Storybook is added, make sure to add it to the run command in the `project.json` under `apps/storybook-composition/targets/storybook-composition/options/commands`.
@@ -235,7 +235,7 @@ Before running the command, go to the `project.json` and add the following to th
235235
```
236236

237237
```sh
238-
npx nx g @nx/react:cypress-component-configuration --project=my-package --build-target=my-package:build --no-interactive
238+
nx g @nx/react:cypress-component-configuration --project=my-package --build-target=my-package:build --no-interactive
239239
```
240240

241241
## Increase Version and Publish
@@ -255,7 +255,31 @@ Before publishing change the out dir in the build setting of the `vite.config.js
255255
Make sure not to forget this flag: `--skip-publish`
256256

257257
```sh
258-
npx nx release --skip-publish
258+
nx release --skip-publish
259259
```
260260
### *Don't forget to Push the automatically commited tag*
261261
Make sure to replace "This was a version bump only, there were no code changes." with the relevant changes in the `CHANGELOG.md`.
262+
263+
## Sync `package.json` Files with Syncpack
264+
265+
Keep your dependencies consistent across your monorepo using [Syncpack](https://github.com/JamieMason/syncpack):
266+
267+
### List Mismatched Dependency Versions
268+
269+
```bash
270+
npx syncpack list-mismatches
271+
```
272+
273+
### Automatically Fix Mismatched Versions
274+
275+
```bash
276+
npx syncpack fix-mismatches
277+
```
278+
279+
## Use Depcheck to Find Unused Dependencies
280+
281+
Go to your package directory and run:
282+
283+
```sh
284+
npx depcheck --skip-missing
285+
```

0 commit comments

Comments
 (0)