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: MonorepoNX-cheatsheet.md
+49-25Lines changed: 49 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,53 +1,53 @@
1
1
# MapComponents Monorepo
2
2
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
8
4
9
5
```bash
10
-
npx syncpack list-mismatches
6
+
npm i -g nx pnpm
11
7
```
12
8
13
-
### Automatically Fix Mismatched Versions
9
+
##Install dependencies
14
10
15
11
```bash
16
-
npx syncpack fix-mismatches
12
+
pnpm install
17
13
```
18
14
19
-
## Use Depcheck to Find Unused Dependencies
15
+
## Run Tasks
20
16
21
-
Go to your package directory and run:
17
+
To see all projects maintained in this monorepo run:
22
18
23
-
```sh
24
-
npx depcheck --skip-missing
19
+
```bash
20
+
nx show projects
25
21
```
26
22
27
-
## Run Tasks
28
-
29
23
To see all available targets to run for a project, run:
30
24
31
25
```sh
32
-
npx nx show project {package-name}
26
+
nx show project {package-name}
33
27
```
34
28
35
29
To run any task from any package, run:
36
30
37
31
```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
39
39
```
40
40
41
41
Alternatively, you can also use:
42
42
43
43
```sh
44
-
npx nx {task-name} {package-name}
44
+
nx {task-name} {package-name}
45
45
```
46
46
47
47
To run all tasks in parallel, use:
48
48
49
49
```sh
50
-
npx nx run-many --target={task-name} --all
50
+
nx run-many --target={task-name} --all
51
51
```
52
52
53
53
## Add New Projects
@@ -56,13 +56,13 @@ To run all tasks in parallel, use:
56
56
To generate a new application, use:
57
57
58
58
```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
60
60
```
61
61
62
62
To generate a new library, use:
63
63
64
64
```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
66
66
```
67
67
68
68
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:
120
120
## Add Storybook to an existing project
121
121
122
122
```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
124
124
```
125
125
126
126
## 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
186
186
This is the command to run all the Storybooks in composition mode locally and in parallel:
187
187
188
188
```shell
189
-
npx nx run storybook-composition:storybook-composition
189
+
nx run storybook-composition:storybook-composition
190
190
```
191
191
192
192
Then, in a new terminal, run:
193
193
194
194
```shell
195
-
npx nx run storybook-composition:storybook
195
+
nx run storybook-composition:storybook
196
196
```
197
197
198
198
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
235
235
```
236
236
237
237
```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
239
239
```
240
240
241
241
## Increase Version and Publish
@@ -255,7 +255,31 @@ Before publishing change the out dir in the build setting of the `vite.config.js
255
255
Make sure not to forget this flag: `--skip-publish`
256
256
257
257
```sh
258
-
npx nx release --skip-publish
258
+
nx release --skip-publish
259
259
```
260
260
### *Don't forget to Push the automatically commited tag*
261
261
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):
0 commit comments