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: CONTRIBUTING.md
+88-14
Original file line number
Diff line number
Diff line change
@@ -19,19 +19,19 @@ your contributions. Please read it carefully and let us know if it's not up-to-d
19
19
into a single commit, so you can use that to frame your scope.
20
20
1. Create a commit with the proposed change changes:
21
21
* Commit title and message (and PR title and description) must adhere to [conventionalcommits].
22
-
* The title must begin with `feat(module): title`, `fix(module): title`,
22
+
* The title must begin with `feat(module): title`, `fix(module): title`,
23
23
`reactor(module): title` or `chore(module): title`.
24
24
* Title should be lowercase.
25
25
* No period at the end of the title.
26
-
* Commit message should describe _motivation_. Think about your code reviewers and what
27
-
information they need in order to understand what you did. If it's a big commit (hopefully not),
26
+
* Commit message should describe _motivation_. Think about your code reviewers and what
27
+
information they need in order to understand what you did. If it's a big commit (hopefully not),
28
28
try to provide some good entry points so it will be easier to follow.
29
29
* Commit message should indicate which issues are fixed: `fixes #<issue>` or `closes #<issue>`.
30
30
* Shout out to collaborators.
31
31
* If not obvious (i.e. from unit tests), describe how you verified that your
32
32
change works.
33
33
* If this commit includes a breaking change, the commit message must end with a
34
-
a single pragraph
34
+
a single pragraph
35
35
`BREAKING CHANGE: description of what broke and how to achieve this beahvior now`.
36
36
2. Push to a fork or to a branch (naming convention: `<user>/<feature-bug-name>`)
37
37
3. Submit a Pull Requests on GitHub and assign the PR for a review to the "awslabs/aws-cdk" team.
@@ -50,32 +50,38 @@ your contributions. Please read it carefully and let us know if it's not up-to-d
50
50
## Tools
51
51
52
52
The CDK is a big project, and, at the moment, all of the CDK modules are mastered in a single monolithic
53
-
repository (uses [lerna](https://github.com/lerna/lerna)). There are pros and cons to this approach,
53
+
repository (uses [lerna](https://github.com/lerna/lerna)). There are pros and cons to this approach,
54
54
and it's especially valuable to maintain integrity in the early stage of thr project where things constantly change across the stack. In the future we believe many of these modules will be extracted to their own repositories.
55
55
56
56
Another complexity is that the CDK is packaged using [jsii](https://github.com/awslabs/jsii) to multiple
57
57
programming languages. This means that when a full build is complete, there will be a version of each
58
58
module for each supported language.
59
59
60
60
However, in many cases, you can probably get away with just building a portion of the
61
-
project, based on areas that you want to work on.
61
+
project, based on areas that you want to work on.
62
+
63
+
We recommend that you use [Visual Studio Code](https://code.visualstudio.com/) to work on the CDK.
64
+
Be sure to install the [tslint extension](https://marketplace.visualstudio.com/items?itemName=eg2.tslint)
65
+
for it as well, since we have strict linting rules that will prevent your code from compiling,
66
+
but with VSCode and this extension can be automatically fixed for you by hitting `Ctrl-.` when
67
+
your cursor is on a red underline.
62
68
63
69
### Main build scripts
64
70
65
71
The build process is divided into stages, so you can invoke them as needed:
66
72
67
73
-__`install.sh`__: installs all external dependencies and symlinks internal dependencies (using `lerna link`).
68
74
-__`build.sh`__: runs `npm build` and `npm test` in all modules (in topological order).
69
-
-__`pack.sh`__: packages all modules to all supported languages and produces a `dist/` directory
70
-
with all the outputs (running this script requires that you installed the [toolchains](#Toolchains)
75
+
-__`pack.sh`__: packages all modules to all supported languages and produces a `dist/` directory
76
+
with all the outputs (running this script requires that you installed the [toolchains](#Toolchains)
71
77
for all target languages on your system).
72
78
73
79
### Partial build tools
74
80
75
81
There are also two useful scripts in the `scripts` directory that can help you build part of the repo:
76
82
77
-
-__`scripts/buildup`__: builds the current module and all of it's dependencies (in topological order).
78
-
-__`scripts/builddown`__: builds the current module and all of it's consumers (in topological order).
83
+
-__`scripts/buildup`__: builds the current module and all of its dependencies (in topological order).
84
+
-__`scripts/builddown`__: builds the current module and all of its consumers (in topological order).
79
85
80
86
### Useful aliases
81
87
@@ -95,7 +101,7 @@ alias lw='lr watch'
95
101
96
102
### pkglint
97
103
98
-
The `pkglint` tool "lints" package.json files across the repo according
104
+
The `pkglint` tool "lints" package.json files across the repo according
99
105
to [rules.ts](tools/pkglint/lib/rules.ts).
100
106
101
107
To evaluate (and attempt to fix) all package linting issues in the repo, run the following command from the root
@@ -131,7 +137,7 @@ $ ./install.sh
131
137
$ ./build.sh
132
138
```
133
139
134
-
If you also wish to package to all languages, make sure you have all the [toolchains](#Toolchains]
140
+
If you also wish to package to all languages, make sure you have all the [toolchains](#Toolchains]
135
141
and now run:
136
142
137
143
```
@@ -140,7 +146,7 @@ $ ./pack.sh
140
146
141
147
### Partial build
142
148
143
-
In many cases, you don't really need to build the entire project. Say you want to work
149
+
In many cases, you don't really need to build the entire project. Say you want to work
144
150
on the `@aws-cdk/aws-ec2` module:
145
151
146
152
```console
@@ -175,7 +181,7 @@ $ nodeunit test/test.*.js
175
181
176
182
### Build Documentation Only
177
183
178
-
The CDK documentation source is hosted under [`./docs/src`](./docs/src).
184
+
The CDK documentation source is hosted under [`./docs/src`](./docs/src).
179
185
Module reference documentation is gathered after build from the `dist/sphinx` directory (generated by jsii from source via the `./pack.sh` script).
180
186
181
187
To build the docs even if reference docs are not present:
@@ -239,6 +245,74 @@ We use `npm update` to
239
245
5. Now, run `./build.sh` again to verify all tests pass.
240
246
6. Submit a Pull Request.
241
247
248
+
### Troubleshooting common issues
249
+
250
+
Most build issues can be solved by doing a full clean rebuild:
251
+
252
+
```shell
253
+
$ git clean -fqdx .
254
+
$ ./build.sh
255
+
```
256
+
257
+
However, this will be time consuming. In this section we'll describe some common issues you may encounter and some more
258
+
targeted commands you can run to resolve your issue.
259
+
260
+
* The compiler is throwing errors on files that I renamed/it's running old tests that I meant to remove/code coverage is
261
+
low and I didn't change anything.
262
+
263
+
If you switch to a branch in which `.ts` files got renamed or deleted, the generated `.js` and `.d.ts` files from the
264
+
previous compilation run are still around and may in some cases still be picked up by the compiler or test runners.
265
+
266
+
Run the following to clear out stale build artifacts:
267
+
268
+
```shell
269
+
$ scripts/clean-stale-files.sh
270
+
```
271
+
272
+
* I added a dependency but it's not being picked up by the build
273
+
274
+
You need to tell Lerna to update all dependencies:
275
+
276
+
```shell
277
+
$ node_modules/.bin/lerna bootstrap
278
+
```
279
+
280
+
* I added a dependency but it's not being picked up by a `watch` background compilation run.
281
+
282
+
No it's not. After re-bootstrapping you need to restart the watch command.
283
+
284
+
* I added a dependency but it's not being picked up by Visual Studio Code (I still get red underlines).
285
+
286
+
The TypeScript compiler that's running has cached your dependency tree. After re-bootstrapping,
287
+
restart the TypeScript compiler.
288
+
289
+
Hit F1, type`> TypeScript: Restart TS Server`.
290
+
291
+
* I'm doing refactorings between packages and compile times are killing me/I need to switch between
292
+
differently-verionsed branches a lot and rebuilds because of version errors are taking too long.
293
+
294
+
Our build steps for each package do a couple of things, such as generating code and generating
295
+
JSII assemblies. If you've done a full build at least once to generate all source files, you can
296
+
do a quicker TypeScript-only rebuild of the entire source tree by doing the following:
297
+
298
+
```shell
299
+
# Only works after at least one full build to generate source files
300
+
$ scripts/build-typescript.sh
301
+
302
+
# Also works to start a project-wide watch compile
303
+
$ scripts/build-typescript.sh -w
304
+
```
305
+
306
+
This does not do code generation and it does not do JSII checks and JSII assembly generation. Instead of doing a
307
+
package-by-package ordered build, it compiles all `.ts` files in the repository all at once. This takes about the same
308
+
time as it does to compile the biggest package all by itself, and on my machine is the difference between a 15
309
+
CPU-minute build and a 20 CPU-second build. If you use this methods of recompiling and you want to run the test, you
310
+
have to disable the built-in rebuild functionality of `lerna run test`:
311
+
312
+
```shell
313
+
$ CDK_TEST_BUILD=false lr test
314
+
```
315
+
242
316
## Toolchains
243
317
244
318
If you wish to use `pack.sh` to package the project to all supported languages, you will need the
There was a problem loading the remainder of the diff.
0 commit comments