|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thank you for your interest in contributing to an Intercom project. |
| 4 | + |
| 5 | +## Table of contents |
| 6 | + |
| 7 | +- [Development](#development) |
| 8 | + - [Installation](#installation) |
| 9 | + - [Project structure](#project-structure) |
| 10 | +- [Code of Conduct](#code-of-conduct) |
| 11 | + - [Our pledge](#our-pledge) |
| 12 | + - [Our standards](#our-standards) |
| 13 | + - [Our responsibilities](#our-responsibilities) |
| 14 | + - [Scope](#scope) |
| 15 | + - [Enforcement](#enforcement) |
| 16 | + - [Attribution](#attribution) |
| 17 | + |
| 18 | +## Development |
| 19 | + |
| 20 | +### Installation |
| 21 | + |
| 22 | +This project is a Rollup-based TypeScript NodeJS library. To get the source and make changes: |
| 23 | + |
| 24 | +```bash |
| 25 | +git clone [email protected]:intercom/contentful-typescript-codegen.git |
| 26 | +cd contentful-typescript-codegen |
| 27 | +yarn install |
| 28 | +``` |
| 29 | + |
| 30 | +To ensure everything is set up correctly: |
| 31 | + |
| 32 | +```bash |
| 33 | +yarn test |
| 34 | +``` |
| 35 | + |
| 36 | +### Project structure |
| 37 | + |
| 38 | +This project consists of three main parts, and the `src/` folder mostly reflects this: |
| 39 | + |
| 40 | +1. The **CLI entry point**, which is responsible for parsing command line arguments, loading the |
| 41 | + Contentful environment from the parent module's setup, and printing the generated TypeScript to |
| 42 | + the specified output location. |
| 43 | +1. The **TypeScript code generators**, which are helpers that print out things like interfaces, |
| 44 | + union types, and other TypeScript type structures. |
| 45 | +1. The **Contentful code generators**, which receive Contentful objects (like Content Types and |
| 46 | + Fields) and use the **TypeScript code generators** to turn them into interfaces. |
| 47 | + |
| 48 | +The TypeScript code generators utilize one another to eventually resolve a giant string. This big, |
| 49 | +ugly string is ultimately passed through Prettier and sent back to the CLI layer to print to a file. |
| 50 | + |
| 51 | +All generators have roughly the following shape: |
| 52 | + |
| 53 | +```ts |
| 54 | +interface Generator { |
| 55 | + (thing: SomeParticularObject, options?: OptionsForGenerator): string |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +Testing mostly consists of snapshot testing. Tests use `prettier`, where applicable, to make the |
| 60 | +snapshots easier to read and to make sure they parse as valid TypeScript. Note that using `prettier` |
| 61 | +on too "narrow" of a test (i.e., _just_ a field) will cause a parser error. In such cases, just let |
| 62 | +the snapshot be ugly and let "broader" tests handle regressions involving potentially unparseable |
| 63 | +code. |
| 64 | + |
| 65 | +## Code of Conduct |
| 66 | + |
| 67 | +### Our pledge |
| 68 | + |
| 69 | +In the interest of fostering an open and welcoming environment, we as |
| 70 | +contributors and maintainers pledge to making participation in our project and |
| 71 | +our community a harassment-free experience for everyone, regardless of age, body |
| 72 | +size, disability, ethnicity, sex characteristics, gender identity and expression, |
| 73 | +level of experience, education, socio-economic status, nationality, personal |
| 74 | +appearance, race, religion, or sexual identity and orientation. |
| 75 | + |
| 76 | +### Our standards |
| 77 | + |
| 78 | +Examples of behavior that contributes to creating a positive environment |
| 79 | +include: |
| 80 | + |
| 81 | +- Using welcoming and inclusive language |
| 82 | +- Being respectful of differing viewpoints and experiences |
| 83 | +- Gracefully accepting constructive criticism |
| 84 | +- Focusing on what is best for the community |
| 85 | +- Showing empathy towards other community members |
| 86 | + |
| 87 | +Examples of unacceptable behavior by participants include: |
| 88 | + |
| 89 | +- The use of sexualized language or imagery and unwelcome sexual attention or |
| 90 | + advances |
| 91 | +- Trolling, insulting/derogatory comments, and personal or political attacks |
| 92 | +- Public or private harassment |
| 93 | +- Publishing others' private information, such as a physical or electronic |
| 94 | + address, without explicit permission |
| 95 | +- Other conduct which could reasonably be considered inappropriate in a |
| 96 | + professional setting |
| 97 | + |
| 98 | +### Our responsibilities |
| 99 | + |
| 100 | +Project maintainers are responsible for clarifying the standards of acceptable |
| 101 | +behavior and are expected to take appropriate and fair corrective action in |
| 102 | +response to any instances of unacceptable behavior. |
| 103 | + |
| 104 | +Project maintainers have the right and responsibility to remove, edit, or |
| 105 | +reject comments, commits, code, wiki edits, issues, and other contributions |
| 106 | +that are not aligned to this Code of Conduct, or to ban temporarily or |
| 107 | +permanently any contributor for other behaviors that they deem inappropriate, |
| 108 | +threatening, offensive, or harmful. |
| 109 | + |
| 110 | +### Scope |
| 111 | + |
| 112 | +This Code of Conduct applies within all project spaces, and it also applies when |
| 113 | +an individual is representing the project or its community in public spaces. |
| 114 | +Examples of representing a project or community include using an official |
| 115 | +project e-mail address, posting via an official social media account, or acting |
| 116 | +as an appointed representative at an online or offline event. Representation of |
| 117 | +a project may be further defined and clarified by project maintainers. |
| 118 | + |
| 119 | +### Enforcement |
| 120 | + |
| 121 | +Instances of abusive, harassing, or otherwise unacceptable behavior may be |
| 122 | +reported by contacting the project team at [email protected]. All |
| 123 | +complaints will be reviewed and investigated and will result in a response that |
| 124 | +is deemed necessary and appropriate to the circumstances. The project team is |
| 125 | +obligated to maintain confidentiality with regard to the reporter of an incident. |
| 126 | +Further details of specific enforcement policies may be posted separately. |
| 127 | + |
| 128 | +Project maintainers who do not follow or enforce the Code of Conduct in good |
| 129 | +faith may face temporary or permanent repercussions as determined by other |
| 130 | +members of the project's leadership. |
| 131 | + |
| 132 | +### Attribution |
| 133 | + |
| 134 | +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, |
| 135 | +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html |
| 136 | + |
| 137 | +[homepage]: https://www.contributor-covenant.org |
| 138 | + |
| 139 | +For answers to common questions about this code of conduct, see |
| 140 | +https://www.contributor-covenant.org/faq |
0 commit comments