|
2 | 2 |
|
3 | 3 | We'd love your help! |
4 | 4 |
|
| 5 | +## Development Quick Start |
| 6 | + |
| 7 | +To get the project started quickly, you can follow these steps. For more |
| 8 | +detailed instructions, see [development](#development) below. |
| 9 | + |
| 10 | +```sh |
| 11 | +git clone https://github.com/open-telemetry/opentelemetry-js.git |
| 12 | +cd opentelemetry-js |
| 13 | +npm install |
| 14 | +npm run compile |
| 15 | +npm test |
| 16 | +``` |
| 17 | + |
5 | 18 | ## Report a bug or requesting feature |
6 | 19 |
|
7 | 20 | Reporting bugs is an important contribution. Please make sure to include: |
@@ -57,15 +70,102 @@ Remember to always work in a branch of your local copy, as you might otherwise h |
57 | 70 |
|
58 | 71 | Please also see [GitHub workflow](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md#github-workflow) section of general project contributing guide. |
59 | 72 |
|
60 | | -### Running the tests |
| 73 | +## Development |
| 74 | + |
| 75 | +### Tools used |
| 76 | + |
| 77 | +- [NPM](https://npmjs.com) |
| 78 | +- [TypeScript](https://www.typescriptlang.org/) |
| 79 | +- [lerna](https://github.com/lerna/lerna) to manage dependencies, compilations, and links between packages. Most lerna commands should be run by calling the provided npm scripts. |
| 80 | +- [MochaJS](https://mochajs.org/) for tests |
| 81 | +- [gts](https://github.com/google/gts) |
| 82 | +- [eslint](https://eslint.org/) |
| 83 | + |
| 84 | +Most of the commands needed for development are accessed as [npm scripts](https://docs.npmjs.com/cli/v6/using-npm/scripts). It is recommended that you use the provided npm scripts instead of using `lerna run` in most cases. |
| 85 | + |
| 86 | +### Install dependencies |
| 87 | + |
| 88 | +This will install all dependencies for the root project and all modules managed by `lerna`. By default, a `postinstall` script will run `lerna bootstrap` automatically after an install. This can be avoided using the `--ignore-scripts` option if desired. |
| 89 | + |
| 90 | +```sh |
| 91 | +npm install |
| 92 | +``` |
| 93 | + |
| 94 | +### Compile modules |
| 95 | + |
| 96 | +All modules are managed as a composite typescript project using [Project References](https://www.typescriptlang.org/docs/handbook/project-references.html). This means that a breaking change in one module will be reflected in compilations of its dependent modules automatically. |
| 97 | + |
| 98 | +DO NOT use lerna to compile all modules unless you know what you are doing because this will cause a new typescript process to be spawned for every module in the project. |
| 99 | + |
| 100 | +```sh |
| 101 | +# Build all modules |
| 102 | +npm run compile |
| 103 | + |
| 104 | +# Remove compiled output |
| 105 | +npm run clean |
| 106 | +``` |
| 107 | + |
| 108 | +These commands can also be run for specific packages instead of the whole project, which can speed up compilations while developing. |
| 109 | + |
| 110 | +```sh |
| 111 | +# Build a single module and all of its dependencies |
| 112 | +cd packages/opentelemetry-module-name |
| 113 | +npm run compile |
| 114 | +``` |
| 115 | + |
| 116 | +Finally, builds can be run continuously as files change using the `watch` npm script. |
| 117 | + |
| 118 | +```sh |
| 119 | +# Build all modules |
| 120 | +npm run watch |
| 121 | + |
| 122 | +# Build a single module and all of its dependencies |
| 123 | +cd packages/opentelemetry-module-name |
| 124 | +npm run watch |
| 125 | +``` |
| 126 | + |
| 127 | +### Running tests |
| 128 | + |
| 129 | +Similar to compilations, tests can be run from the root to run all tests or from a single module to run only the tests for that module. |
| 130 | + |
| 131 | +```sh |
| 132 | +# Test all modules |
| 133 | +npm test |
| 134 | + |
| 135 | +# Test a single module |
| 136 | +cd packages/opentelemetry-module-name |
| 137 | +npm test |
| 138 | +``` |
| 139 | + |
| 140 | +### Linting |
| 141 | + |
| 142 | +This project uses a combination of `gts` and `eslint`. Just like tests and compilation, linting can be done for all packages or only a single package. |
| 143 | + |
| 144 | +```sh |
| 145 | +# Lint all modules |
| 146 | +npm lint |
| 147 | + |
| 148 | +# Lint a single module |
| 149 | +cd packages/opentelemetry-module-name |
| 150 | +npm lint |
| 151 | +``` |
| 152 | + |
| 153 | +There is also a script which will automatically fix many linting errors. |
| 154 | + |
| 155 | +```sh |
| 156 | +# Lint all modules, fixing errors |
| 157 | +npm lint:fix |
| 158 | + |
| 159 | +# Lint a single module, fixing errors |
| 160 | +cd packages/opentelemetry-module-name |
| 161 | +npm lint:fix |
| 162 | +``` |
| 163 | + |
| 164 | +### Adding a package |
61 | 165 |
|
62 | | -The `opentelemetry-js` project is written in TypeScript. |
| 166 | +To add a new package, copy `packages/template` to your new package directory and modify the `package.json` file to reflect your desired package settings. If the package will not support browser, the `karma.conf` file may be deleted. If the package will support es5 targets, the reference to `tsconfig.base.json` in `tsconfig.json` should be changed to `tsconfig.es5.json`. |
63 | 167 |
|
64 | | -- `npm install` to install dependencies. |
65 | | -- `npm run compile` compiles the code, checking for type errors. |
66 | | -- `npm run bootstrap` Bootstrap the packages in the current Lerna repo. Installs all of their dependencies and links any cross-dependencies. |
67 | | -- `npm test` tests code the same way that our CI will test it. |
68 | | -- `npm run lint:fix` lint (and maybe fix) any changes. |
| 168 | +After adding the package, run `npm install` from the root of the project. This will update the `tsconfig.json` project references automatically and install all dependencies in your new package. |
69 | 169 |
|
70 | 170 | ### Guidelines for Pull Requests |
71 | 171 |
|
|
0 commit comments