|
1 | 1 | # How to contribute to LINE Bot SDK for Node.js
|
2 | 2 |
|
3 | 3 | First of all, thank you so much for taking your time to contribute! LINE Bot SDK
|
4 |
| -for Node.js is not very different from any other open source projects. It will |
5 |
| -be fantastic if you help us by doing any of the following: |
| 4 | +for Node.js is not very different from any other open source projects you are aware of. It will |
| 5 | +be amazing if you could help us by doing any of the following: |
6 | 6 |
|
7 |
| -- File an issue in [the issue tracker](https://github.com/line/line-bot-sdk-nodejs/issues) |
8 |
| - to report bugs and propose new features and improvements. |
9 |
| -- Ask a question using [the issue tracker](https://github.com/line/line-bot-sdk-nodejs/issues). |
| 7 | +- File an issue in [the issue tracker](https://github.com/line/line-bot-sdk-nodejs/issues) to report bugs and propose new features and improvements. |
| 8 | +- Ask a question using [the issue tracker](https://github.com/line/line-bot-sdk-nodejs/issues) (__Please ask only about this SDK__). |
10 | 9 | - Contribute your work by sending [a pull request](https://github.com/line/line-bot-sdk-nodejs/pulls).
|
11 | 10 |
|
12 | 11 | ## Development
|
13 | 12 |
|
14 |
| -You can freely fork the project, clone the forked repository, and start editing. |
| 13 | +### Install dependencies |
15 | 14 |
|
16 |
| -Here are each top-level directory explained: |
| 15 | +Run `npm install` to install all dependencies for development. |
17 | 16 |
|
18 |
| -* `lib`: TypeScript source code. You may modify files under this directory. |
19 |
| -* `test`: Test suites. Please add tests for modification if possible. |
20 |
| -* `examples`: Example projects using this SDK |
21 |
| -* `docs`: [VitePress](https://vitepress.dev/) markdowns for project documentation |
22 |
| -* `tools`: Useful tools |
| 17 | +### Understand the project structure |
23 | 18 |
|
24 |
| -Also, you may use the following npm scripts for development: |
| 19 | +The project structure is as follows: |
25 | 20 |
|
26 |
| -* `npm run test`: Run test suites in `test`. |
27 |
| -* `npm run format`: Format source code with [Prettier](https://github.com/prettier/prettier) |
28 |
| -* `npm run format:check`: Silently run `format` and report formatting errors |
29 |
| -* `npm run build`: Build TypeScript code into JavaScript. The built files will |
30 |
| - be placed in `dist/`. |
31 |
| -* `npm run docs`: Build and serve documentation |
| 21 | +- `lib`: The main library code. |
| 22 | +- `test`: Test code. |
| 23 | +- `examples`: Example projects that use the library. |
| 24 | +- `docs`: [VitePress](https://vitepress.dev/) markdowns for project documentation. |
| 25 | +- `generator`: Custom OpenAPI generator implementation for this SDK. |
32 | 26 |
|
33 |
| -We test, lint and build on CI, but it is always nice to check them before |
34 |
| -uploading a pull request. |
| 27 | +### Edit OpenAPI templates |
| 28 | + |
| 29 | +Almost all API client code is generated with OpenAPI Generator based on [line-openapi](https://github.com/line/line-openapi)'s YAML files. |
| 30 | +Thus, you cannot edit most code under `lib` directory directly. |
| 31 | + |
| 32 | +You need to edit the custom generator templates under the `generator` directory instead. |
| 33 | + |
| 34 | +After editing the templates, run the `generate-code.py` script to generate the code, and then commit all affected files. |
| 35 | +If not, CI status will fail. |
| 36 | + |
| 37 | +When you update code, be sure to check consistencies between generated code and your changes. |
| 38 | + |
| 39 | +### Add unit tests |
| 40 | + |
| 41 | +We use [Vitest](https://vitest.dev/) for unit tests. |
| 42 | +Please add tests to the appropriate test directories to verify your changes. |
| 43 | + |
| 44 | +Especially for bug fixes, please follow this flow for testing and development: |
| 45 | +1. Write a test before making changes to the library and confirm that the test fails. |
| 46 | +2. Modify the code of the library. |
| 47 | +3. Run the test again and confirm that it passes thanks to your changes. |
| 48 | + |
| 49 | +### Run your code in your local |
| 50 | + |
| 51 | +You can use the example projects to test your changes locally before submitting a pull request. |
| 52 | + |
| 53 | +### Run CI tasks in your local |
| 54 | + |
| 55 | +The following npm scripts are available for development: |
| 56 | + |
| 57 | +* `npm run test`: Run test suites using Vitest. |
| 58 | +* `npm run format`: Format source code with [Prettier](https://github.com/prettier/prettier). |
| 59 | +* `npm run build`: Build TypeScript code into JavaScript. The built files will be placed in `dist/`. |
| 60 | + |
| 61 | +We test, lint and build on CI, but it is always nice to check them before uploading a pull request. |
| 62 | +For details on the commands executed in the CI, please refer to `.github/workflows/test.yml`. |
| 63 | + |
| 64 | +### Documentation |
| 65 | +This project uses two documentation systems: |
| 66 | + |
| 67 | +1. **API Reference Documentation** - Generated with [TypeDoc](https://typedoc.org/) |
| 68 | + - Source is automatically generated from JSDoc comments in the code |
| 69 | + - Output files are located in the `docs/apidocs` directory |
| 70 | + - To generate API documentation, run: `npm run apidocs` |
| 71 | + |
| 72 | +2. **User Documentation** - Built with [VitePress](https://vitepress.dev/) |
| 73 | + - Source files are located in the `docs` directory |
| 74 | + - Contains guides, tutorials, and general usage information |
| 75 | + - To build and serve user documentation locally, run: `npm run docs` |
| 76 | + |
| 77 | +**Please make sure your new or modified code is covered by proper JSDoc comments.** |
| 78 | +Good documentation ensures that contributors and users can easily read and understand how the methods and classes work. |
35 | 79 |
|
36 | 80 | ## Contributor license agreement
|
37 | 81 |
|
|
0 commit comments