In this monorepo project you will find the following projects:
Public packages:
- packages/haring-react: Contains the basic UI components
- packages/haring-react-shared: Contains the shared UI components and functions
- packages/haring-react-dates: Contains the date related components
- packages/haring-react-dropzone: Contains the dropzone components
- packages/haring-react-table: Contains the table components
Private configuration packages:
- packages/eslint-config-custom: Shared eslint configuration
- packages/storybook: Storybook global stories
- packages/test: Shared jest configuration
- packages/tsconfig: Shared typescript configuration
Private integration testing packages:
- apps/next: Next.js testing app
At the root level you can launch following commands:
npm run build
: Builds all packages projectsnpm run build:app
: Builds all apps projectsnpm run dev
: Launches dev command in apps projectsnpm run start
: Launches start command in apps projectsnpm run lint
: Lints everythingnpm run lint:root
: Lints everything but theapps
foldernpm run lint:fix
: Lints and fix everything but theapps
foldernpm run test
: Launches all unit testsnpm run format
: Reformats all filesnpm run changeset
: Creates a changeset file ( see Submitting a pull request)npm run storybook
: Launches the global storybooknpm run storybook:no-open
: Launches the global storybook without opening a new tab
The following commands are used on the CI:
npm run build-storybook
: Builds the static version of storybooknpm run serve-and-test-storybook
: Launches storybook interaction tests
Inside all haring*
directories you can launch following commands:
npm run build
: Builds the librarynpm run test
: Runs unit tests
To create a new component use the dedicated command npm run generate
.
You will asked multiple questions and in the end it should generate:
- the base component file
- the base storybook file
- the base test file
- and it will export the component in the
index.tsx
file
Components are by default created as client component (with 'use client';
).
If you are not creating a client component, don't forget to remove this line.
In order to maintain consistency and quality, all code has to follow the project's conventions and best practices described in the Best Practices guide.
When creating a component, the generator will automatically create a snapshot
test for you (in the Component.test.tsx
file).
Don't forget to add required props in the test file.
Maybe add other snapshot tests for special cases.
And if you have to manage a state in your component, please create an interaction test in the storybook: https://storybook.js.org/docs/react/writing-tests/interaction-testing
You can find examples in existing components.
Shared functions are located in the helpers
directory.
All these functions must be unit tested.
We uses changesets to manage versioning. When submitting a PR add a changeset which contains what packages should be bumped, their associated semver bump types and some markdown which will be inserted into changelogs.
To create a changeset:
- Run
npm run changeset
- This will create a changeset file in the
.changeset
folder you can review - Commit the changeset file
When a PR containing changesets is merged into *.x
branch it will
automatically create a release PR.
Then when that release PR is merged into the *.x
branch, it will automatically
create a release and publish the packages on npm
.