@enable-tech/shared-types
Version:
This package represents the single source of truth of the Types being used in the codebase (front-end and back-end) of enable.tech, It is an organization-scoped package. So, all the development teams belonging to it can participate to enhance it.
105 lines (77 loc) • 3.54 kB
Markdown
# enable-tech-shared-types
This package represents the single source of truth for the Types used in the codebase (front-end and mobile) of enable.tech
## Installation
```sh
npm i @enable-tech/shared-types
```
## Usage
Right now the package contains some of the modules we use in front-end apps (4 MFEs apps & public pages app) and Enable Rewards (mobile app) exported as modules in "src/index.ts"
so if we are working in any app we can install the package and auto-import any of the types that are exported for the completed modules (all the modules are going to be added)
Check the screenshot to see an example of how to use it

as you can see if you don't remember what is being exported you can easily see what it included by dot notation & the autocomplete for TypeScript will result in 2 results so you can choose which one to use
Also, you can add an alias for the path in the consumer project if you wish too
After a new version of the package is published you need to update it through the following command
```sh
npm update @enable-tech/shared-types
```
## Contributing
All the development team can contribute
you would need to do the following steps
1. Clone the repo
```sh
git clone https://github.com/EButler-QA/enable-tech-shared-types.git
```
2. Install the dependencies
```sh
npm install
```
3. If there is a new module to which we want to add the types, it shall be added to This directory 'src/modules' following convention [convention](https://docs.google.com/document/d/1Ct-3p_8QOm3WBZVX4i1h0WQ3OZdxLC7jyi5DyTKRp3I/edit?tab=t.0)
Don't forget to export the new modules at this file 'src/index.ts' as it represents the index to the package
4. After adding the new updates to the package, you can use the scripts in the package.json file to make sure that everything is working fine before linking and testing.
- Run the following command to ensure there are no ESLint errors across the project (If there are any errors, fix them before linking):
```sh
npm run prepublish
```
- To test the new updates locally after running the previous commands, link the package in the current project:
```sh
npm run start
```
Then, in the consumer project, link the shared types package by running:
```sh
yarn link "@enable-tech/shared-types"
```
Note:
- The rules of ESlint are provided in this file '.eslintrc.cjs' so if you want to add any extra config feel free to do so
- In the '.eslintrc.cjs' file The following rule
```sh
rules: {
'@typescript-eslint/no-explicit-any': ['off'],
},
```
is only added because there are explicit 'any' for some of the types that are supposed to be typed by the schema of DTOs so once the back-end adds them we are going to remove this rule & follow strict types without 'any'
- Run the following command to format all files using Prettier & add them to be committed
```sh
npm run version
```
5. Provide a new version
```sh
npm version <update_type>
```
The version of the package would mainly be represented as a major.minor.patch so replace <update_type> with the equivalent
example updating the patch would be
```sh
npm version patch
```
6. Finally, Publish it 🥳
```sh
npm login
```
```sh
cd build
```
```sh
npm publish --access public
```
## Author
**Mayar Elabbasy**