@common-stack/generate-plugin 6.0.6-alpha.6 → 6.0.6-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/generators/add-frontend/generator.cjs +1 -1
  3. package/lib/generators/add-frontend/generator.cjs.map +1 -1
  4. package/lib/generators/add-frontend/generator.mjs +1 -1
  5. package/lib/generators/add-frontend/generator.mjs.map +1 -1
  6. package/lib/generators/add-frontend/templates/package.json +3 -2
  7. package/lib/generators/add-fullstack/files/package.json +3 -3
  8. package/package.json +2 -2
  9. package/src/generators/add-frontend/generator.ts +2 -1
  10. package/src/generators/add-fullstack/files/package.json +3 -3
  11. package/lib/generators/add-fullstack/files/docs/Moleculer.md +0 -10
  12. package/lib/generators/add-fullstack/files/docs/References.md +0 -13
  13. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/Adding_New_Modules.md +0 -84
  14. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/Desktop_Setup.md +0 -12
  15. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/DoAndDont.md +0 -35
  16. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/GitHooks.md +0 -3
  17. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/HowToContribute.md +0 -14
  18. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/How_to_Run_Various_Options.md +0 -95
  19. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/Known_Issues.md +0 -19
  20. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/Lint_And_Formatter.md +0 -9
  21. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/Project_Setup.md +0 -159
  22. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/Dynamically_Render_Components.md +0 -57
  23. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/HOC_With_Render_Props.md +0 -87
  24. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/Mongoose_Connection.md +0 -45
  25. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/React_Componet_Extensions.md +0 -11
  26. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/RxJS_notes.md +0 -3
  27. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/Styles_With_Type.md +0 -52
  28. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/Tutorials.md +0 -12
  29. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/faq.md +0 -17
  30. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/installation_issues.md +0 -9
  31. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/lerna-build-tools.md +0 -504
  32. package/lib/generators/add-fullstack/files/docs/development/CodeContribution/lerna-yarn-workspaces.md +0 -82
  33. package/lib/generators/add-fullstack/files/docs/development/Database/mongodb-test.md +0 -6
  34. package/lib/generators/add-fullstack/files/docs/development/Deployment/How_To_Setup_Jenkins.md +0 -60
  35. package/lib/generators/add-fullstack/files/docs/development/Deployment/JenkinsDeployment.md +0 -16
  36. package/lib/generators/add-fullstack/files/docs/development/Expo/expo-commands.md +0 -5
  37. package/lib/generators/add-fullstack/files/docs/development/Mobile/How_To_Make_Expo_Wrok_With_Monorepos.md +0 -9
  38. package/lib/generators/add-fullstack/files/docs/development/Mobile/React-Native-FAQ.md +0 -4
  39. package/lib/generators/add-fullstack/files/docs/development/Mobile/Run_mobile.md +0 -9
  40. package/src/generators/add-fullstack/files/docs/Moleculer.md +0 -10
  41. package/src/generators/add-fullstack/files/docs/References.md +0 -13
  42. package/src/generators/add-fullstack/files/docs/development/CodeContribution/Adding_New_Modules.md +0 -84
  43. package/src/generators/add-fullstack/files/docs/development/CodeContribution/Desktop_Setup.md +0 -12
  44. package/src/generators/add-fullstack/files/docs/development/CodeContribution/DoAndDont.md +0 -35
  45. package/src/generators/add-fullstack/files/docs/development/CodeContribution/GitHooks.md +0 -3
  46. package/src/generators/add-fullstack/files/docs/development/CodeContribution/HowToContribute.md +0 -14
  47. package/src/generators/add-fullstack/files/docs/development/CodeContribution/How_to_Run_Various_Options.md +0 -95
  48. package/src/generators/add-fullstack/files/docs/development/CodeContribution/Known_Issues.md +0 -19
  49. package/src/generators/add-fullstack/files/docs/development/CodeContribution/Lint_And_Formatter.md +0 -9
  50. package/src/generators/add-fullstack/files/docs/development/CodeContribution/Project_Setup.md +0 -159
  51. package/src/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/Dynamically_Render_Components.md +0 -57
  52. package/src/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/HOC_With_Render_Props.md +0 -87
  53. package/src/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/Mongoose_Connection.md +0 -45
  54. package/src/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/React_Componet_Extensions.md +0 -11
  55. package/src/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/RxJS_notes.md +0 -3
  56. package/src/generators/add-fullstack/files/docs/development/CodeContribution/React-Patterns/Styles_With_Type.md +0 -52
  57. package/src/generators/add-fullstack/files/docs/development/CodeContribution/Tutorials.md +0 -12
  58. package/src/generators/add-fullstack/files/docs/development/CodeContribution/faq.md +0 -17
  59. package/src/generators/add-fullstack/files/docs/development/CodeContribution/installation_issues.md +0 -9
  60. package/src/generators/add-fullstack/files/docs/development/CodeContribution/lerna-build-tools.md +0 -504
  61. package/src/generators/add-fullstack/files/docs/development/CodeContribution/lerna-yarn-workspaces.md +0 -82
  62. package/src/generators/add-fullstack/files/docs/development/Database/mongodb-test.md +0 -6
  63. package/src/generators/add-fullstack/files/docs/development/Deployment/How_To_Setup_Jenkins.md +0 -60
  64. package/src/generators/add-fullstack/files/docs/development/Deployment/JenkinsDeployment.md +0 -16
  65. package/src/generators/add-fullstack/files/docs/development/Expo/expo-commands.md +0 -5
  66. package/src/generators/add-fullstack/files/docs/development/Mobile/How_To_Make_Expo_Wrok_With_Monorepos.md +0 -9
  67. package/src/generators/add-fullstack/files/docs/development/Mobile/React-Native-FAQ.md +0 -4
  68. package/src/generators/add-fullstack/files/docs/development/Mobile/Run_mobile.md +0 -9
@@ -1,52 +0,0 @@
1
-
2
- Sample Style Sheet implementation.
3
-
4
- ```js
5
- import * as CSS from 'csstype';
6
- import { css } from '@emotion/react'
7
-
8
- const DefaultSettingsView = (props: IDefaultSettings) => {
9
-
10
-
11
- return(()=> {
12
- <div className={css(styleSheet.title({title:title}))}>
13
- <span className={css(styleSheet.note({ width: width || 0 }))}>test</span>
14
- </div>
15
- })
16
-
17
- }
18
- const styleSheet: { [key: string]: (x: any) => CSS.Properties } = {
19
- resizable: {
20
- position: 'relative',
21
- '> .react-resizable-handle': {
22
- position: 'absolute',
23
- width: '3px',
24
- height: '100%',
25
- top: 0,
26
- right: 0,
27
- padding: '0 3px 3px 0',
28
- boxSizing: 'border-box',
29
- cursor: 'col-resize',
30
- },
31
- },
32
- title: ({ theme }) => ({
33
- textTransform: 'uppercase',
34
- padding: '5px 0',
35
- fontSize: '11px',
36
- marginLeft: '33px',
37
- color: theme.name === 'light' ? '#424242bd' : '#e7e7e77a',
38
- boxShadow: theme.name === 'light' ? '0px 1px 2px 0px #f3f3f3' : '0px 1px 2px 0px #000000',
39
- marginBottom: '2px',
40
- }),
41
- note: ({ width }) => ({
42
- marginLeft: '33px',
43
- fontSize: '14px',
44
- whiteSpace: 'nowrap',
45
- textOverflow: 'clip',
46
- display: 'block',
47
- maxWidth: width,
48
- overflow: 'hidden',
49
- }),
50
- };
51
-
52
- ```
@@ -1,12 +0,0 @@
1
-
2
-
3
- Typescript Tutorials
4
- ---
5
- https://basarat.gitbooks.io/typescript/
6
- https://medium.com/@martin_hotell/react-children-composition-patterns-with-typescript-56dfc8923c64
7
-
8
-
9
-
10
- Cors:
11
- ---
12
- https://www.blackhillsinfosec.com/cors-lite/
@@ -1,17 +0,0 @@
1
- ---
2
- id: faq-build
3
- title: Babel, JSX, and Build Steps
4
- permalink: docs/faq-build.html
5
- layout: docs
6
- category: FAQ
7
- ---
8
-
9
-
10
- ### From where this `@sample-stack/platform-browser` comes in `packages/sample-platform/browser/src/containers/Counter.tsx`?
11
-
12
- We use [lerna](https://github.com/lerna/lerna) for monorepo. For example all packages starts with `@sample-stack` are either under `packages` or `pacakges-modules` directories.
13
-
14
-
15
- ### What is use of rehydrate?
16
-
17
- It is used for SSR(server side rendering). Server generates initial browser page along with state(redux or apollo-client or css) and that state will be used in the browser to rehydated during browser rendering so the client state don't start from initial values.
@@ -1,9 +0,0 @@
1
-
2
-
3
-
4
- 1. Error when `node-gyp rebuild`.
5
- Could be missing `python`. Install it and rerun the install again.
6
- For more docs, check https://github.com/nodejs/node-gyp#installation
7
-
8
- 2. For Mac User to develop Desktop app need
9
- `xcode-select --install`
@@ -1,504 +0,0 @@
1
-
2
- What is lerna?
3
- ===
4
- [Lerna](https://github.com/lerna/lerna) allows us to manage multiple packages inside the same repository instead of creating one repository per package. With Lerna, we can unify processes like linting, building, testing, and releasing, have a single place to report issues, and becomes easier to set up our development environment.
5
-
6
-
7
- Things to know about current package structure
8
- --
9
- - We run `lerna` commands by wrapped into `npm/yarn` commands.
10
- - You will notice there are following commands which run's lerna comamnds.
11
-
12
- ```json
13
- {
14
- ...
15
- "lerna:prepublish": "git checkout publish && git merge -s recursive -X theirs master",
16
- "lerna:prepublish:develop": "git checkout publish-develop && git merge -s recursive -X theirs develop",
17
- "watch": "lerna exec --no-sort --ignore *server --stream --parallel -- webpack --watch",
18
- "publish": "yarn lerna:prepublish && lerna publish",
19
- "lerna": "lerna bootstrap --hoist",
20
- "postinstall": "yarn lerna",
21
- "clean": "lerna clean",
22
- "build": "yarn build:packages",
23
- "build:packages": "lerna run build --ignore *server",
24
- "build:packages:watch": "lerna run build:lib:watch --ignore *server --stream",
25
- "watch-packages": "lerna exec --no-sort --scope @sample-stack/platform* --scope @sample-stack/react-shared-components --scope @sample-stack/core --stream --parallel 'webpack --watch'",
26
- ...
27
- }
28
- ```
29
-
30
- Details on each command that wrapped for lerna
31
- --
32
- - `yarn install` - This command need to be run in the root of the package only to install all the dependencies. We have post step(`postinstall`) to run `yarn lerna` after install finishes so `lerna` will installs all of packages (seen under packages directory) dependencies and links any cross-dependencies.
33
- Note: We do not need to run `yarn` under any packages with `package.json` files seen under `packages` and `servers` directories.
34
- - `yarn lerna` - This triggers `lerna bootstrap --hoist`. Normally this get triggered as post install step. You can run this command to install any packages' dependencies. More information about this command can be found [here](https://github.com/lerna/lerna/blob/master/doc/hoist.md). The bottom line, the `hoist` will try to install all common dependencies to the top-level node_modules, and omitted from individual package's `node_modules`.
35
- The outlier packages with different versions will get a normal, local node_modules installation of the necessary dependencies.
36
- - `yarn clean` - Removes the `node_modules` directory from all packages.
37
- - `yarn clean:force` - Removes the `node_modules` directory from all packages as well as `package-lock.json` file.
38
- - `yarn build` - It invokes `yarn build` in each packages parallely.
39
- - `yarn watch` - Automatically builds the packages that are changed. Recommended to run this when actively coding, so you would know anything (compilation errors) breaks instantly. You may also see `Error: ENOSPC: System limit for number of file watchers reached` if you OS is not configured with high open files. Check [Not Enough Watchers](#not-enough-watchers) section for futher information.
40
- - `yarn watch-packages` - Abutomatically builds the dependent packages mostly under `packages` folder.
41
- - `yarn watch-packages -- --scope @sample-stack/counter-module-*` - By adding package module you like to watch along with the dependent packages. If you have more packages to watch keep adding with `-- --scope packageA* --scope packageB`
42
-
43
-
44
-
45
- Not Enough Watchers
46
- ----
47
- Based on the project, we may have multiple `packages` and `packages-modules` to watch for file changes in order to automatically apply the changes in the browser.
48
- When we have more modules to watch, we need laptop resource to support it. If the laptop OS is configured with default `open files`, we need to increase it.
49
- Follow notes from webpack to change OS configuration to increase file watchers https://webpack.js.org/configuration/watch/#not-enough-watchers
50
-
51
- But, in case, if you are working in only one or two modules and need to watch them only then you can run below command on each packages,
52
- respectively.
53
-
54
- `lerna exec --scope=<package name> yarn watch`
55
-
56
- example: run them in different command tabs for all (package1, package2, pacakge3) packages to watch.
57
-
58
- ```
59
- lerna exec --scope=@sample-stack/counter-module-browser yarn watch
60
- lerna exec --scope=@sample-stack/counter-module-server yarn watch
61
- ```
62
-
63
- Adding packages as dependencies to sibling packages (not needed anymore)
64
- --
65
- When you add sibling package to one of the packages, you need to run `yarn lerna` symlink the packages that are dependencies of each other.
66
-
67
-
68
- ### List packages
69
-
70
- Using the following folder structure, versions, and privacy as an example:
71
-
72
- ```bash
73
- fullstack-pro/
74
- ├── packages
75
- │   ├── sample-core # 1.1.1 - public
76
- │   ├── sample-platform
77
- │   │   ├── browser # 1.1.1 - public
78
- │   │   └── server # 1.1.1 - public
79
- │ ...
80
- ├── packages-modules
81
- │   └── counter
82
- │   │ ├── browser
83
- │   │ └── server
84
- ├── servers
85
- │   ├── backend-server # 1.0.0 - private
86
- │   ├── frontend-server # 1.0.0 - private
87
- │ ...
88
- |── package.json
89
- └── lerna.json # 1.1.1
90
- ```
91
-
92
- List all public packages
93
-
94
- ```bash
95
- lerna ls
96
-
97
- # result
98
- @sample-stack/counter-module-browser
99
- @sample-stack/counter-module-server
100
- @sample-stack/core
101
- @sample-stack/platform-browser
102
- @sample-stack/platform-server
103
- @sample-stack/store
104
- ```
105
-
106
- List all packages (public and private)
107
-
108
- ```bash
109
- lerna ls --all
110
-
111
- # result
112
- @sample-stack/counter-module-browser
113
- @sample-stack/counter-module-server
114
- @sample-stack/core
115
- @sample-stack/platform-browser
116
- @sample-stack/platform-server
117
- @sample-stack/store
118
- sample-stack-desktop (PRIVATE)
119
- sample-stack-mobile (PRIVATE)
120
- sample-stack-backend-server (PRIVATE)
121
- sample-stack-frontend-server (PRIVATE)
122
- sample-stack-moleculer-server (PRIVATE)
123
- ```
124
-
125
- List all public packages with more details
126
-
127
- ```bash
128
- lerna ll
129
- # or
130
- lerna ls -l
131
-
132
- # result
133
- @sample-stack/counter-module-browser v0.0.1 packages-modules/counter/browser
134
- @sample-stack/counter-module-server v0.0.1 packages-modules/counter/server
135
- @sample-stack/core v0.0.1 packages/sample-core
136
- @sample-stack/platform-browser v0.0.1 packages/sample-platform/browser
137
- @sample-stack/platform-server v0.0.1 packages/sample-platform/server
138
- @sample-stack/store v0.0.1 packages/sample-store
139
- ```
140
-
141
- List all public and private packages with details
142
-
143
- ```bash
144
- lerna la
145
- # or
146
- lerna ls -la
147
-
148
- # result
149
- @sample-stack/counter-module-browser v0.0.1 packages-modules/counter/browser
150
- @sample-stack/counter-module-server v0.0.1 packages-modules/counter/server
151
- @sample-stack/core v0.0.1 packages/sample-core
152
- @sample-stack/platform-browser v0.0.1 packages/sample-platform/browser
153
- @sample-stack/platform-server v0.0.1 packages/sample-platform/server
154
- @sample-stack/store v0.0.1 packages/sample-store
155
- sample-stack-desktop v0.0.1 portable-devices/desktop (PRIVATE)
156
- sample-stack-mobile v0.0.1 portable-devices/mobile (PRIVATE)
157
- sample-stack-backend-server v0.0.1 servers/backend-server (PRIVATE)
158
- sample-stack-frontend-server v0.0.1 servers/frontend-server (PRIVATE)
159
- sample-stack-moleculer-server v0.0.1 servers/moleculer-server (PRIVATE)
160
- ```
161
-
162
- ## Packages vs Scoped Packages
163
-
164
- All npm packages have a name. Some also have a scope. Scopes are a way of grouping related packages together.
165
-
166
- When we sign up for an npm user account or create an organization, we can use a scope that matches our user or organization name. The same happens for Github Packages Registry. In both registries, my username is **sample-stack**, so my scope is also **sample-stack**.
167
-
168
- Using packages without a scope, we can easily have naming conflicts with other person packages. For example, we can not create a package named jquery on npm because it already exists.
169
-
170
- When we use scoped packages, naming is not a problem because we are naming packages inside our scope.
171
-
172
- If I were creating a new scoped package called **core**, its name in the **package.json** file would be **@sample-stack/core**.
173
-
174
- ## Dependencies
175
- The dependencies of our projects are registered inside the **package.json** file. This file is usually in the project's root folder, but it is also inside each package in the Lerna projects. **Each package has its dependencies.**
176
-
177
- ```bash
178
- fullstack-pro/
179
- ├── packages
180
- │   ├── sample-core
181
- │   │   ├── package.json
182
- │   │   └── ...
183
- │   ├── sample-platform
184
- │   │   ├── browser
185
- │ │   │   ├── package.json
186
- │ │   │   └── ...
187
- │   │   └── server
188
- │ │   │   ├── package.json
189
- │ │   │   └── ...
190
- │ ...
191
- ├── packages-modules
192
- │   └── counter
193
- │   │ ├── browser
194
- │ │   │   ├── package.json
195
- │ │   │   └── ...
196
- │   │ └── server
197
- │ │   │   ├── package.json
198
- │ │   │   └── ...
199
- ├── servers
200
- │   ├── backend-server
201
- │   │   ├── package.json
202
- │   │   └── ...
203
- │   ├── frontend-server
204
- │   │   ├── package.json
205
- │   │   └── ...
206
- │ ...
207
- |── package.json
208
- └── lerna.json
209
- ```
210
- To add dependencies to the packages, Lerna provides us the command `lerna add`. Note that only a single package can be added at a time compared to `yarn add` or `yarn install`.
211
-
212
- ### Add dependencies
213
-
214
- The **dependencies** key must contain all the dependencies our project/application/package/library needs to work in production. **We know when we must declare it as a dependency when its absence has side effects on your production build.**
215
-
216
- **Adding dependencies**
217
-
218
- ```bash
219
- # add a dependency to one package
220
- lerna add lodash --scope=@sample-stack/counter-module-browser
221
-
222
- # add a dependency to several packages
223
- lerna add lodash packages-modules/counter-*
224
-
225
- # add a dependency to all packages
226
- lerna add lodash
227
-
228
- # add a dependency on the root package.json
229
- lerna add lodash -w
230
- ```
231
-
232
- ### Add devDependencies
233
-
234
- The **devDependencies** key must contain all the **dependencies we use during development or needed during the build of our production bundle**. To add a dependency as devDependency just add the flag `--dev`.
235
-
236
- ```bash
237
- # add a devDependency to one package
238
- lerna add lodash --scope=@sample-stack/counter-module-browser --dev
239
-
240
- # add a devDependency to several packages
241
- lerna add lodash packages-modules/counter-* --dev
242
-
243
- # add a devDependency to all packages
244
- lerna add lodash --dev
245
-
246
- # add a devDependency on the root package.json
247
- lerna add lodash -w --dev
248
- ```
249
-
250
- ### Add peerDependencies
251
-
252
- The **peerDependencies** key is **used when our package has a dependency that can also be a dependency of the project using it**. If our package has a dependency that can also be used by its dependent, we can specify the version required by us and the dependent will receive a warning when not matching that requirement.
253
-
254
- ```bash
255
- # add a peerDependency to one package
256
- lerna add lodash --scope=@sample-stack/counter-module-browser --peer
257
-
258
- # add a peerDependency to several packages
259
- lerna add lodash packages-modules/counter-* --peer
260
-
261
- # add a peerDependency to all packages
262
- lerna add lodash --peer
263
- ```
264
-
265
- ### Updating dependencies
266
-
267
- Well, that is a problem. Lerna has no direct command to upgrade dependencies, which is ok when we want to update a dependency in the root package.json. We can use yarn as usually:
268
-
269
- ```bash
270
- # update a dependency on the root package.json
271
- yarn upgrade lodash
272
- ```
273
-
274
- However, when we want to upgrade a dependency inside a package, nothing seems to work. Using `lerna exec` as we use it to remove dependencies does not work.
275
-
276
- For now, what we do is manually update the dependencies version in the `package.json` file of each package and then run `yarn install`.
277
-
278
-
279
- ### Updating all sub packages of a **scoped** packages to newest release
280
-
281
- To update in all packages
282
- ```
283
- lerna exec "ncu -u --semverLevel minor --timeout 60000 -f /@sample-stack*/"
284
- ```
285
-
286
- To update in the root package.json
287
- ```
288
- ncu -u --semverLevel minor --timeout 60000 -f /@sample-stack*/
289
- ```
290
-
291
- To update the major version. You need to check with team before updating major version
292
- ```
293
- lerna exec "ncu -u --semverLevel major --timeout 60000 -f /@sample-stack*/"
294
- ```
295
- ***note** after updating packages you need to run `yarn` to install them.
296
-
297
- ### Removing dependencies
298
-
299
- Lerna also has no direct way to allow us to remove dependencies from the project or packages but we can use the `lerna exec` and `yarn remove` commands to go around it.
300
-
301
- `lerna exec` allow us to run a specific command within a particular package, several packages (using a glob expression), or in all of them. Using it with `yarn remove` we can remove dependencies from the packages. Using `yarn remove` alone we can also remove dependencies from the root package.json.
302
-
303
- ```bash
304
- # remove a dependency to one package
305
- lerna exec --scope @sample-stack/counter-module-browser -- yarn remove lodash
306
-
307
- # remove a dependency to several packages
308
- lerna exec --scope @sample-stack/counter-* -- yarn remove lodash
309
-
310
- # remove a dependency to all packages
311
- lerna exec -- yarn remove lodash
312
-
313
- # remove a dependency from the root package.json
314
- yarn remove lodash
315
- ```
316
-
317
- ### List modified packages
318
-
319
- Like the `git status` command that shows us the files that we modified, Lerna provides us the command `lerna changed` that shows us the packages (not the files) that we modified compared to the remote repository.
320
-
321
- ```bash
322
- lerna changed
323
- ```
324
-
325
- ### Diffing
326
-
327
- **All modifications**
328
-
329
- Like the `git diff` command but ignoring the files outside the packages, Lerna provides us the command `lerna diff` that shows us all the code modifications we did. We can also provide a package name to see only the modifications to that package.
330
-
331
- ```bash
332
- # all modifications
333
- lerna diff
334
-
335
- # modifications in a specific package
336
- lerna diff @sample-stack/counter-module-browser
337
- ```
338
- ## Publish
339
-
340
- To publish our packages using Lerna we use the command `lerna publish` but, first, let's configure Lerna only to allow us to create newer versions of our packages from our main branch (eg. master).
341
-
342
- ```json[lerna.json]
343
- {
344
- "version": "0.0.0",
345
- "command": {
346
- "version": {
347
- "allowBranch": "master"
348
- }
349
- }
350
- }
351
- ```
352
-
353
- Now, if we try to run `lerna publish` inside another branch, it will fail. As highlighted in the [Lerna documentation](https://github.com/lerna/lerna/tree/main/commands/version#--allow-branch-glob), this is a best practice that can save us some problems.
354
-
355
- To publish a **scoped package** we also need to set the `publishConfig.access` to `true` in its **package.json**:
356
-
357
- ```json[packages/sample-core/package.json]
358
- {
359
- "name": "@sample-stack/core",
360
- "version": "0.0.0",
361
- "publishConfig": {
362
- "access": "public"
363
- }
364
- }
365
- ```
366
- Setting this configuration in a package without a scope fails to publish.
367
-
368
- Imagine that we started developing the **sample-core** package, and although we merged some initial versions, we didn't finish yet, and **we don't want to release it to npm yet**. We can add to its **package.json** the **private** key with the value `true`, and Lerna will ignore it.
369
-
370
- ```json[packages/sample-core/package.json]
371
- {
372
- "name": "app-button",
373
- "version": "0.0.0",
374
- "private": true
375
- }
376
- ```
377
-
378
- ### npm
379
-
380
- To publish to npm, first, we need to have an npm account.
381
-
382
- We can see if we are logged in running:
383
-
384
- ```bash
385
- npm whoami
386
- ```
387
-
388
- In case we are not, we do it running:
389
-
390
- ```bash
391
- npm login
392
- ```
393
-
394
- Once we are logged in we can run:
395
-
396
- ```bash
397
- lerna publish
398
- ```
399
-
400
- Which prompts possible versions to update each package. It's up to us to select the right ones based on what we have done. Check the [Semantic Versioning Specification](https://semver.org/) for more information about versioning.
401
-
402
- ### Github Package Registry
403
-
404
- To publish in the Github Packages Registry, we need some extra configurations.
405
-
406
- First, in the **package.json** of each package, we must specify the repository where our code lives.
407
-
408
- ```json[package.json]
409
- {
410
- ...
411
- "repository" : {
412
- "type" : "git",
413
- "url": "ssh://git@github.com:cdmbase/fullstack-pro.git"
414
- }
415
- }
416
- ```
417
-
418
- Then, in the **lerna.json** file, we must specify the registry to publish the packages. By default, it is the npm registry. We have to change it to the `https://npm.pkg.github.com`.
419
-
420
- ```json[lerna.json]
421
- {
422
- "packages": [
423
- "packages/*"
424
- ],
425
- "version": "0.0.0",
426
- "command": {
427
- "version": {
428
- "allowBranch": "master"
429
- },
430
- "publish": {
431
- "registry": "https://npm.pkg.github.com"
432
- }
433
- }
434
- }
435
- ```
436
-
437
- We also have to create a personal token on GitHub with the permissions to read and write packages (`read:packages` and `write:packages`).
438
-
439
- Using the generated token as a password, we authenticate on GitHub Package Registry:
440
-
441
- ```bash
442
- $ npm login --registry=https://npm.pkg.github.com
443
- > Username: USERNAME
444
- > Password: TOKEN
445
- > Email: PUBLIC EMAIL ADDRESS
446
- ```
447
-
448
- And we are ready to publish packages:
449
-
450
- ```bash
451
- lerna publish
452
- ```
453
-
454
- ## Conventional Commits
455
-
456
- Lerna allows us to use the [Conventional Commits Specification](https://www.conventionalcommits.org/) to determine the bump version and generate the CHANGELOG.md files automatically.
457
-
458
- Follow the specification, when we are creating a new release, Lerna checks all the commits since the last release and it increments:
459
- - the PATCH number when the subject of the commit is prefixed with `fix:`;
460
- - the MINOR number when the subject of the commit is prefixed with `feat:`. It has precedence over the PATCH;
461
- - the MAJOR number when in the body of some commit it finds a string `BREAKING CHANGE:`. It can have any type provided in the subject and it has precedence over PATCH and MINOR.
462
-
463
- Considering that we are using fixed versions and our project is in the version `1.0.0`. If we try to create a new release with the following commit, our project version is updated to `1.0.1`.
464
- ```bash
465
- # commit 1
466
- subject -> "fix: fix button font size"
467
- ```
468
-
469
- Then, if we do two more commits and publish again, the version is updated to `1.1.0`.
470
- ```bash
471
- # commit 1
472
- subject -> "fix: fix button border-radius"
473
- # commit 2
474
- subject -> "feat: added loading status to the button"
475
- ```
476
-
477
- Finally, if we do three more commits, the version is updated to `2.0.0`.
478
- ```bash
479
- # commit 1
480
- subject -> "fix: fix button text color"
481
- # commit 2
482
- subject -> "feat: added outlined style"
483
- # commit 3
484
- subject -> "feat: changed the loading property to isLoading"
485
- body: "BREAKING CHANGE: loading prop must be updated to isLoading"
486
- ```
487
-
488
- ### Configuration
489
-
490
- To do that, we update our `lerna.json` file:
491
-
492
- ```bash
493
- {
494
- ...
495
- "command": {
496
- "publish": {
497
- "conventionalCommits": true,
498
- "yes": true
499
- }
500
- }
501
- }
502
- ```
503
-
504
- Now, when we run `lerna publish` instead of asking us what version we want to give to each package, it automatically determines and publishes those versions.
@@ -1,82 +0,0 @@
1
- ## Introduction
2
-
3
- [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) allow us to run `yarn install` only once, although we have several packages. Yarn uses a single lock file rather than a different one for each project, which means fewer conflicts. Once all the dependencies are installed together, Yarn can better optimize them. Its most important feature is that when we have one package depending on another package of our repository, yarn link them together, allowing us to use always the most up-to-date code available.
4
-
5
-
6
- ## Yarn & Yarn Workspaces
7
-
8
- ### Set up yarn
9
-
10
- To configure Lerna to use yarn under the hood, we need to go to the **lerna.json** file and add the **npmClient** key with the value `yarn`. Its value is `npm` by default.
11
-
12
- ```json[lerna.json]
13
- {
14
- "packages": [
15
- "packages/*",
16
- ],
17
- "version": "0.0.0",
18
- "npmClient": "yarn"
19
- }
20
- ```
21
-
22
- ### Set up yarn workspaces
23
-
24
- To configure Lerna to use Yarn Workspaces, first, we need to [Set up yarn](#set-up-yarn). Then we have to configure it in the **lerna.json** and **package.json** files.
25
-
26
- To do so, let's use the following folder structure as an example:
27
-
28
- ```bash
29
- fullstack-pro
30
- ├── packages
31
- │   ├── sample-core/
32
- │   ├── sample-platform/
33
- │   │   ├── browser
34
- │   │   └── server/
35
- │ ...
36
- ├── portable-devices
37
- │   └── desktop
38
- │   └── mobile
39
- ├── packages-modules
40
- │   └── counter
41
- │   │ ├── browser/
42
- │   │ └── server/
43
- ├── servers
44
- │   ├── backend-server/
45
- │   ├── frontend-server/
46
- │ ...
47
- |── package.json
48
- └── lerna.json
49
- ```
50
-
51
- In the **package.json** file, we add the **workspaces** key with a list of globs that indicates the folders where we want to store our packages.
52
-
53
- ```json[package.json]
54
- {
55
- "name": "root",
56
- "private": true,
57
- "workspaces": [
58
- "packages": [
59
- "portable-devices/*",
60
- "packages-modules/**",
61
- "packages/**",
62
- "servers/*"
63
- ]
64
- ],
65
- "devDependencies": {
66
- "lerna": "^3.22.1"
67
- }
68
- }
69
- ```
70
-
71
- In the **lerna.json** file, we can remove the **packages** key because the **workspaces** key in the **package.json** file overrides it. We also need to add the **useWorkspaces** key with the value `true`.
72
-
73
- ```json[lerna.json]
74
- {
75
- "version": "0.0.0",
76
- "npmClient": "yarn",
77
- "useWorkspaces": true
78
- }
79
- ```
80
-
81
- ### Lerna
82
- - [Getting Started with lerna](./lerna-build-tools.md)
@@ -1,6 +0,0 @@
1
-
2
-
3
- Writing Mongodb test
4
- ---
5
-
6
- https://jestjs.io/docs/en/mongodb