Skip to content

Scheduling infrastructure for absolutely everyone.

fix: atoms for local development (#22178)

Lauris Skraucisd74d99dde7ff
diff --git a/packages/platform/atoms/.gitignore b/packages/platform/atoms/.gitignore
index 3014a83b3b1..d15342fc8d5 100644
--- a/packages/platform/atoms/.gitignore
+++ b/packages/platform/atoms/.gitignore
@@ -1 +1,2 @@
-globals.min.css
\ No newline at end of file
+globals.min.css
+cal-atoms-dev.tgz
\ No newline at end of file
diff --git a/packages/platform/atoms/package.json b/packages/platform/atoms/package.json
index 09223861da9..b103fcbf112 100644
--- a/packages/platform/atoms/package.json
+++ b/packages/platform/atoms/package.json
@@ -9,7 +9,8 @@
"dev": "yarn vite build --watch & npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify --watch",
"build": "NODE_OPTIONS='--max_old_space_size=12288' rm -rf dist && yarn vite build && npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify && mkdir ./dist/packages/prisma-client && cp -rf ../../../node_modules/.prisma/client/*.d.ts ./dist/packages/prisma-client",
"publish-npm": "yarn build && npm publish --access public",
- "test": "jest"
+ "test": "jest",
+ "pack-dev": "yarn build && npm pack && mv calcom-atoms-*.tgz cal-atoms-dev.tgz"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
diff --git a/packages/platform/examples/base/README.md b/packages/platform/examples/base/README.md
index baf47d5c43e..0aa486ebd24 100644
--- a/packages/platform/examples/base/README.md
+++ b/packages/platform/examples/base/README.md
@@ -19,7 +19,7 @@ REDIS_URL="redis://localhost:6379"
```
3. Start "apps/api/v2" api using `yarn dev`.
-4. Start "packages/platform/atoms" atoms package with `yarn dev`.
+4. Setup "packages/platform/atoms" by running `yarn atoms-dev-on` in the example app directory - it will pack atoms into a dev .tgz and switch the dependency to point to it. When you are done with development, run `yarn atoms-dev-off` to switch back to the published version because otherwise examples app would have entry in the yarn.lock file pointing to the dev .tgz and installation would fail in prod because dev tar file exists only locally.
5. Start "apps/web" cal web app using `yarn dx`.
6. Open your browser at "http://localhost:3000/" and login with admin username `[email protected]` and password `ADMINadmin2022!`.
7. In the web app navigate to `http://localhost:3000/settings/organizations/new` and create a sample organization. When asked for phone verification code enter `111111`.
diff --git a/packages/platform/examples/base/atoms-dev-on.sh b/packages/platform/examples/base/atoms-dev-on.sh
new file mode 100755
index 00000000000..a02ea13e2e7
--- /dev/null
+++ b/packages/platform/examples/base/atoms-dev-on.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+
+echo "πŸ“¦ Packing @calcom/atoms into dev .tgz..."
+yarn workspace @calcom/atoms pack-dev
+
+echo "πŸ”§ Switching @calcom/atoms to dev .tgz..."
+
+# Detect platform for sed compatibility
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ sed -i '' 's|"@calcom/atoms": ".*"|"@calcom/atoms": "file:../../atoms/cal-atoms-dev.tgz"|' package.json
+else
+ sed -i 's|"@calcom/atoms": ".*"|"@calcom/atoms": "file:../../atoms/cal-atoms-dev.tgz"|' package.json
+fi
+
+yarn install
+
+echo "βœ… Local atoms .tgz linked. Ready for dev."
diff --git a/packages/platform/examples/base/package.json b/packages/platform/examples/base/package.json
index a27ba6a1c65..ffd7179bc7d 100644
--- a/packages/platform/examples/base/package.json
+++ b/packages/platform/examples/base/package.json
@@ -4,6 +4,8 @@
"private": true,
"scripts": {
"dev": "PORT=4321 next dev",
+ "atoms-dev-on": "./atoms-dev-on.sh",
+ "atoms-dev-off": "git checkout -- package.json ../../../../yarn.lock",
"build": "next build",
"start": "next start",
"lint": "next lint"