From eb0768917cba58eb4f1864e0a2d7926cbfde97f9 Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:13:41 +0300 Subject: [PATCH] chore: readme platform libraries (#15737) * chore: readme platform libraries * fixup! chore: readme platform libraries * fixup! fixup! chore: readme platform libraries * Update README.md * Update README.md --- .../features/auth/lib/getServerSession.ts | 4 +- packages/platform/libraries/README.md | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 packages/platform/libraries/README.md diff --git a/packages/features/auth/lib/getServerSession.ts b/packages/features/auth/lib/getServerSession.ts index 734debd0e7..1fde417d38 100644 --- a/packages/features/auth/lib/getServerSession.ts +++ b/packages/features/auth/lib/getServerSession.ts @@ -1,4 +1,4 @@ -import { LRUCache } from "lru-cache"; +import * as lruCache from "lru-cache"; import type { GetServerSidePropsContext, NextApiRequest, NextApiResponse } from "next"; import type { AuthOptions, Session } from "next-auth"; import { getToken } from "next-auth/jwt"; @@ -15,7 +15,7 @@ const log = logger.getSubLogger({ prefix: ["getServerSession"] }); * Stores the session in memory using the stringified token as the key. * */ -const CACHE = new LRUCache({ max: 1000 }); +const CACHE = new lruCache.LRUCache({ max: 1000 }); /** * This is a slimmed down version of the `getServerSession` function from diff --git a/packages/platform/libraries/README.md b/packages/platform/libraries/README.md new file mode 100644 index 0000000000..b1187caf5f --- /dev/null +++ b/packages/platform/libraries/README.md @@ -0,0 +1,42 @@ +# How to work with platform libraries in Dev + +whenever you want to change anything in platform libraries, or if you modify the code of one of the functions imported in libraries you will need to build the code again. + +first thing to know is that we version this package using NPM + +https://www.npmjs.com/package/@calcom/platform-libraries?activeTab=code + +In order to work using the locally built platform libraries you need to: + +- in packages/platform/libraries/package.json set the version to for example 1.2.3 + +- in apps/api/v2/package.json add to dependencies: + "@calcom/platform-libraries-1.2.3": "npm:@calcom/platform-libraries@1.2.3" + +- in api v2 code simply import using the new alias: + import { + getAllUserBookings as getAllUserBookings1.2.3, + } from "@calcom/platform-libraries-1.2.3"; + + +since the versions are matching in both package.json yarn will try to use the locally built code + +now go to packages/platform/libraries and do + +- yarn build + +then go back to /apps/api/v2 and run + +- yarn + +- yarn dev + +# Before Merging to main +- Publish Your Version of Libraries on NPM: + - To publish, ensure you are a contributor to the platform libraries' NPM package. + - Authenticate yourself via the CLI using npm auth. + - Increment the version number accordingly. + - Run yarn publish to publish your version. +- Once it's published, change back the version in packages/platform/libraries/package.json back to 0.0.0 +- Run yarn +- You should now be using the npm package instead of the locally built version