@enable-tech/shared-types
v2.0.6
Published
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.
Readme
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
npm i @enable-tech/shared-typesUsage
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
npm update @enable-tech/shared-typesContributing
All the development team can contribute you would need to do the following steps
Clone the repo
git clone https://github.com/EButler-QA/enable-tech-shared-types.gitInstall the dependencies
npm installIf 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
Don't forget to export the new modules at this file 'src/index.ts' as it represents the index to the package
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):
npm run prepublishTo test the new updates locally after running the previous commands, link the package in the current project:
npm run startThen, in the consumer project, link the shared types package by running:
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
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'rules: { '@typescript-eslint/no-explicit-any': ['off'], },
Run the following command to format all files using Prettier & add them to be committed
npm run version
Provide a new version
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
npm version patchFinally, Publish it 🥳
npm logincd buildnpm publish --access public
Author
Mayar Elabbasy