chore: add dev docs on mintlify (#16935)
* --init * progress... * add more docs * bunch of changes and added back platform * development guides added * more guides in develop with cal * self hosted WIP * deployments * fix deployment steps * self-hosted guides * .. * Removed the development only sections * Removed 'with Cal.com' * use steps component for steps --------- Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
1 parent
66378160df
commit
da55306a5a
55 files changed
+2964
-681
No files matched your search
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: "Code styling"
|
||||
icon: "pen-fancy"
|
||||
---
|
||||
|
||||
Keeping our code styles consistent is key to making the repository easy to read and work with.
|
||||
|
||||
We use a number of style guides written by other amazing companies, simply because they are widely used and because we like working with them.
|
||||
|
||||
We don't expect you to study every single rule of each style guide, but these are great reference points as to how your code should be styled. We may reject a pull request if your code style significantly differs from these style guides however.
|
||||
|
||||
### ESLint & Prettier
|
||||
Calendso uses the ESLint and Prettier formatting tools, and the repository comes with defined rules for each tool. We recommend setting up both tools and using these to help automatically style your code to our guidelines.
|
||||
|
||||
### JavaScript/TypeScript
|
||||
We use the
|
||||
for all JavaScript and Typescript code.
|
||||
|
||||
### HTML & CSS
|
||||
We use the [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) for any HTML and CSS markup. However, exceptions to the HTML guide apply where JSX differentiates from standard HTML.
|
||||
@@ -0,0 +1,164 @@
|
||||
---
|
||||
title: "Contributor's Guide"
|
||||
icon: "book-open"
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Cal.com is structured as a monorepo using [Turborepo](https://github.com/vercel/turbo). Cal.com is built on [NextJS]("https://github.com/vercel/next.js") with [Typescript]("https://www.typescriptlang.org/"), [PostgreSQL]("https://www.postgresql.org/") database and the interactions with the database are carried out using [Prisma]("https://www.prisma.io/"). We use [TRPC]("https://trpc.io/") for end-to-end typesafe procedure calls to Prisma and utilize [Zod]("https://zod.dev/") for validation and type-safe parsing of API calls.
|
||||
|
||||
## Setting Up the Development Environment
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Here is what you need to be able to run Cal.com.
|
||||
- Node.js (Version: >=18.x)
|
||||
- PostgreSQL
|
||||
- Yarn (recommended)
|
||||
|
||||
Cal.com can be set up and run on your machine locally. Please take a look at [this quick guide](https://cal.com/documentation/getting-started/local-development) for instructions on setting it up.
|
||||
|
||||
|
||||
<iframe
|
||||
width="560"
|
||||
height="315"
|
||||
title="Run cal.com locally"
|
||||
src="https://www.loom.com/embed/2f9d16b0959c4f1eaa5b306300ea4deb"
|
||||
frameborder="0"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
></iframe>
|
||||
|
||||
|
||||
## Understanding the Project Structure
|
||||
|
||||
Cal.com makes use of Turborepo for a monorepo structure. This allows us to manage multiple code projects (like libraries, apps, services) and share code and resources effectively.
|
||||
|
||||
You can look at [turbo.json](https://github.com/calcom/cal.com/blob/main/turbo.json) to see how we use it. In simple terms,
|
||||
- Each entry in the `pipeline` section corresponds to a different part of the project. Understanding these will help in navigating the codebase.
|
||||
- Knowing which tasks depend on others is crucial for understanding the build process.
|
||||
- The `env` entries under each task highlight the need for specific configuration settings, which you will need to set up in your development environment.
|
||||
- You should focus on the tasks related to the area you are contributing to. For example, if working on the Prisma schema, look at tasks prefixed with `@calcom/prisma`
|
||||
- The various packages can be found in the [/packages](https://github.com/calcom/cal.com/tree/main/packages) folder from the root.
|
||||
- The various pages and components for the web can be found in the [/apps/web](https://github.com/calcom/cal.com/tree/main/apps/web) folder from the root.
|
||||
- The public API related codebase can be found in the [/apps/api](https://github.com/calcom/cal.com/tree/main/apps/api) folder from the root.
|
||||
- The Cal.ai related codebase can be found in the [/apps/ai](https://github.com/calcom/cal.com/tree/main/apps/ai) folder from the root
|
||||
|
||||
## How we use TRPC at cal.com
|
||||
|
||||
Cal.com makes use of the TRPC calls for CRUD operations on the database by utilizing the [useQuery()](https://trpc.io/docs/client/react/useQuery) & [useMutation()](https://trpc.io/docs/client/react/useMutation) hooks. These are essentially wrappers around @tanstack/react-query and you can learn more about them here, respectively: [queries](https://tanstack.com/query/v4/docs/react/guides/queries), [mutations](https://tanstack.com/query/v4/docs/react/guides/mutations).
|
||||
|
||||
Here’s an example usage of useQuery at cal.com:
|
||||
```JS
|
||||
const { data: webhooks } = trpc.viewer.webhook.list.useQuery(undefined, {
|
||||
suspense: true,
|
||||
enabled: session.status === "authenticated",
|
||||
});
|
||||
```
|
||||
|
||||
Here’s an example usage of useMutation at cal.com:
|
||||
```JS
|
||||
const createWebhookMutation = trpc.viewer.webhook.create.useMutation({
|
||||
async onSuccess() {
|
||||
showToast(t("webhook_created_successfully"), "success");
|
||||
await utils.viewer.webhook.list.invalidate();
|
||||
router.back();
|
||||
},
|
||||
onError(error) {
|
||||
showToast(`${error.message}`, "error");
|
||||
},
|
||||
});
|
||||
```
|
||||
Both the examples are taken from [packages/features/webhooks/pages/webhook-new-view.tsx](https://github.com/calcom/cal.com/blob/main/packages/features/webhooks/pages/webhook-new-view.tsx) file. We use the useQuery hook for fetching data from the database. On the contrary, the useMutation hook is used for Creating/Updating/Deleting data from the database.
|
||||
|
||||
The path prior to the useQuery or useMutation hook represents the actual path of the procedure: in this case, [packages/trpc/server/routers/viewer/webhook](https://github.com/calcom/cal.com/tree/main/packages/trpc/server/routers/viewer/webhook). You will find `create.handler.ts` in case of
|
||||
```js
|
||||
trpc.viewer.webhook.create.useMutation()
|
||||
```
|
||||
& `list.handler.ts` in case of
|
||||
```js
|
||||
trpc.viewer.webhook.list.useQuery()
|
||||
```
|
||||
in the path mentioned above. There is usually a schema file in the same directory for each handler as well (_name_.schema.ts). This is generally how we make use of the TRPC calls in the cal.com repo.
|
||||
|
||||
## The Cal.com API V1
|
||||
|
||||
Our [API V1](https://github.com/calcom/cal.com/tree/main/apps/api) uses [zod validations](https://zod.dev/) to keep us typesafe and give us extensive parsing control and error handling. These validations reside in [/apps/api/lib/validations](https://github.com/calcom/cal.com/tree/main/apps/api/lib/validations). We also have [helper](https://github.com/calcom/cal.com/tree/main/apps/api/lib/helpers) and [utility](https://github.com/calcom/cal.com/tree/main/apps/api/lib/utils) functions which are used primarily within our API endpoints.
|
||||
Here’s an example usage of our [zod validation in action with the respective API endpoint](https://github.com/calcom/cal.com/blob/main/apps/api/lib/validations/destination-calendar.ts):
|
||||
```js
|
||||
export const schemaDestinationCalendarBaseBodyParams = DestinationCalendar.pick({
|
||||
integration: true,
|
||||
externalId: true,
|
||||
eventTypeId: true,
|
||||
bookingId: true,
|
||||
userId: true,
|
||||
}).partial();
|
||||
|
||||
const schemaDestinationCalendarCreateParams = z
|
||||
.object({
|
||||
integration: z.string(),
|
||||
externalId: z.string(),
|
||||
eventTypeId: z.number().optional(),
|
||||
bookingId: z.number().optional(),
|
||||
userId: z.number().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
export const schemaDestinationCalendarCreateBodyParams = schemaDestinationCalendarBaseBodyParams.merge(
|
||||
schemaDestinationCalendarCreateParams
|
||||
);
|
||||
```
|
||||
|
||||
And here’s the usage of this validation for parsing the request at the [respective endpoint](https://github.com/calcom/cal.com/blob/main/apps/api/pages/api/destination-calendars/_post.ts):
|
||||
```js
|
||||
async function postHandler(req: NextApiRequest) {
|
||||
const { userId, isAdmin, prisma, body } = req;
|
||||
const parsedBody = schemaDestinationCalendarCreateBodyParams.parse(body);
|
||||
```
|
||||
This is the general approach of validation and parsing in our API submodule.
|
||||
|
||||
## Building Apps for Cal.com
|
||||
|
||||
We’ve got an app store containing apps which complement the scheduling platform. From video conferencing apps such as Zoom, Google Meet, etc. to Calendar Apps such as Google Calendar, Apple Calendar, CalDAV, etc. and even payment, automation, analytics and other miscellaneous apps, it is an amazing space to improve the scheduling experience.
|
||||
|
||||
We have a CLI script in place that makes building apps a breeze. [You can learn more about it here](https://cal.com/docs/how-to-guides/how-to-build-an-app).
|
||||
|
||||
## Running Tests
|
||||
|
||||
### E2E-Testing
|
||||
|
||||
Be sure to set the environment variable `NEXTAUTH_URL` to the correct value. If you are running locally, as the documentation within `.env.example` mentions, the value should be `http://localhost:3000`.
|
||||
|
||||
In a terminal just run:
|
||||
```bash
|
||||
yarn test-e2e
|
||||
```
|
||||
|
||||
To open the last HTML report run:
|
||||
|
||||
```bash
|
||||
`yarn playwright show-report test-results/reports/playwright-html-report`
|
||||
```
|
||||
|
||||
#### Resolving issues
|
||||
|
||||
**E2E test browsers not installed**
|
||||
|
||||
If you face the following error when running `yarn test-e2e`:
|
||||
|
||||
<Warning>
|
||||
Executable doesn't exist at /Users/alice/Library/Caches/ms-playwright/chromium-1048/chrome-mac/Chromium.app
|
||||
</Warning>
|
||||
|
||||
You can resolve it by running:
|
||||
|
||||
```bash
|
||||
npx playwright install
|
||||
```
|
||||
to download test browsers.
|
||||
|
||||
## Contribution and Collaboration Guides
|
||||
|
||||
- [Code Styling Guide](/developing/open-source-contribution/code-styling)
|
||||
- [Pull Requests Guide](/developing/open-source-contribution/pull-requests)
|
||||
@@ -0,0 +1,137 @@
|
||||
---
|
||||
title: "Introduction"
|
||||
icon: "github"
|
||||
---
|
||||
|
||||
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
||||
|
||||
- Before jumping into a PR be sure to search [existing PRs](https://github.com/calcom/cal.com/pulls) or [issues](https://github.com/calcom/cal.com/issues) for an open or closed item that relates to your submission.
|
||||
|
||||
### Priorities
|
||||
|
||||
| Type of issue | Priority |
|
||||
| :-------------------------------------------------------------- | :-------------------------------------------------- |
|
||||
| Minor improvements, non-core feature requests | <img className="m-0" noZoom src="./images/low-priority.svg" /> |
|
||||
| Confusing UX (... but working) | <img className="m-0" noZoom src="./images/medium-priority.svg" /> |
|
||||
| Core Features (Booking page, availabilty, timezone calculation) | <img className="m-0" noZoom src="./images/high-priority.svg" /> |
|
||||
| Core Bugs (Login, Booking page, Emails are not working) | <img className="m-0" noZoom src="./images/urgent-priority.svg" /> |
|
||||
|
||||
|
||||
### Developing
|
||||
|
||||
The development branch is `main`. This is the branch that all pull
|
||||
requests should be made against. The changes on the `main`
|
||||
branch are tagged into a release monthly.
|
||||
|
||||
To develop locally:
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your
|
||||
own GitHub account and then
|
||||
[clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
|
||||
2. Create a new branch:
|
||||
|
||||
```bash
|
||||
git checkout -b MY_BRANCH_NAME
|
||||
```
|
||||
|
||||
3. Install yarn:
|
||||
|
||||
```bash
|
||||
npm install -g yarn
|
||||
```
|
||||
|
||||
4. Install the dependencies with:
|
||||
|
||||
```bash
|
||||
yarn
|
||||
```
|
||||
|
||||
5. Start developing and watch for code changes:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
### Building
|
||||
|
||||
You can build the project with:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
Please be sure that you can make a full production build before pushing code.
|
||||
|
||||
### Testing
|
||||
|
||||
More info on how to add new tests coming soon.
|
||||
|
||||
### Running tests
|
||||
|
||||
This will run and test all flows in multiple Chromium windows to verify that no critical flow breaks:
|
||||
|
||||
```bash
|
||||
yarn test-e2e
|
||||
```
|
||||
|
||||
### Linting
|
||||
|
||||
To check the formatting of your code:
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
||||
If you get errors, be sure to fix them before committing.
|
||||
|
||||
### Making a Pull Request
|
||||
|
||||
- Be sure to [check the "Allow edits from maintainers" option](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) while creating you PR.
|
||||
- If your PR refers to or fixes an issue, be sure to add `refs #XXX` or `fixes #XXX` to the PR description. Replacing `XXX` with the respective issue number. See more about [Linking a pull request to an issue
|
||||
](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).
|
||||
- Be sure to fill the PR Template accordingly.
|
||||
|
||||
### Guidelines for committing yarn lockfile
|
||||
|
||||
Do not commit your `yarn.lock` unless you've made changes to the `package.json`. If you've already committed `yarn.lock` unintentionally, follow these steps to undo:
|
||||
|
||||
If your last commit has the `yarn.lock` file alongside other files and you only wish to uncommit the `yarn.lock`:
|
||||
```git
|
||||
git checkout HEAD~1 yarn.lock
|
||||
git commit -m "Revert yarn.lock changes"
|
||||
```
|
||||
If you've pushed the commit with the `yarn.lock`:
|
||||
1. Correct the commit locally using the above method.
|
||||
2. Carefully force push:
|
||||
|
||||
```git
|
||||
git push origin <your-branch-name> --force
|
||||
```
|
||||
|
||||
If `yarn.lock` was committed a while ago and there have been several commits since, you can use the following steps to revert just the `yarn.lock` changes without impacting the subsequent changes:
|
||||
|
||||
1. **Checkout a Previous Version**:
|
||||
- Find the commit hash before the `yarn.lock` was unintentionally committed. You can do this by viewing the Git log:
|
||||
```git
|
||||
git log yarn.lock
|
||||
```
|
||||
- Once you have identified the commit hash, use it to checkout the previous version of `yarn.lock`:
|
||||
```git
|
||||
git checkout <commit_hash> yarn.lock
|
||||
```
|
||||
|
||||
2. **Commit the Reverted Version**:
|
||||
- After checking out the previous version of the `yarn.lock`, commit this change:
|
||||
```git
|
||||
git commit -m "Revert yarn.lock to its state before unintended changes"
|
||||
```
|
||||
|
||||
3. **Proceed with Caution**:
|
||||
- If you need to push this change, first pull the latest changes from your remote branch to ensure you're not overwriting other recent changes:
|
||||
```git
|
||||
git pull origin <your-branch-name>
|
||||
```
|
||||
- Then push the updated branch:
|
||||
```git
|
||||
git push origin <your-branch-name>
|
||||
```
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: "Pull requests"
|
||||
icon: "code-pull-request"
|
||||
---
|
||||
|
||||
### Requirements
|
||||
|
||||
We have a number of requirements for PRs to ensure they are as easy to review as possible and to ensure that they are up to standard with the code.
|
||||
|
||||
### Title & Content
|
||||
|
||||
|
||||
Start by providing a short and concise title. Don’t put something generic (e.g. bug fixes), and instead mention more specifically what your PR achieves, for instance “Fixes dropdown not expanding on settings page”.
|
||||
|
||||
For the PR description, you should go into much greater detail about what your PR adds or fixes. Firstly, the description should include a link to any relevant issues or discussions surrounding the feature or bug that your PR addresses.
|
||||
|
||||
### Feature PRs
|
||||
|
||||
Give a functional overview of how your feature works, including how the user can use the feature. Then, share any technical details in an overview of how the PR works (e.g. “Once the user enters their password, the password is hashed using BCrypt and stored in the Users database field”).
|
||||
|
||||
### Bug Fix PRs
|
||||
|
||||
Give an overview of how your PR fixes the bug both as a high-level overview and a technical explanation of what caused the issue and how your PR resolves this.
|
||||
|
||||
Feel free to add a short video or screenshots of what your PR achieves. Loom is a great way of sharing short videos.
|
||||
|
||||
### Code Quality & Styling
|
||||
|
||||
All submitted code must match our [code styling](/code-styling) standards. We will reject pull requests that differ significantly from our standardised code styles.
|
||||
|
||||
All code is automatically checked by Codacy and our linting process, and will notify you if there are any issues with the code that you submit. We require that code passes these quality checks before merging.
|
||||
|
||||
### PR review process
|
||||
|
||||
At least two members of the Cal.com team should review and approve any PR before it is merged.
|
||||
|
||||
Once two members of the team have approved this, someone from the team will merge the PR. If you are part of the Cal.com team, you should merge your own PRs once you have received both approvals.
|
||||
Reference in new issue
Block a user