fix: Add version to embed.js and preview.js (#16182)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
"embed-web-start": "yarn workspace @calcom/web start",
|
||||
"__build": "yarn tailwind && vite build && tsc --emitDeclarationOnly --declarationDir dist && cp -r ../../../apps/web/public/embed ./dist/",
|
||||
"__dev": "yarn tailwind && vite build --mode development",
|
||||
"build": "rm -rf dist && NEXT_PUBLIC_EMBED_FINGER_PRINT=$(git rev-parse --short HEAD) yarn __build",
|
||||
"build": "rm -rf dist && NEXT_PUBLIC_EMBED_FINGER_PRINT=$(git rev-parse --short HEAD) NEXT_PUBLIC_EMBED_VERSION=$(node -p 'require(\"./package.json\").version') yarn __build",
|
||||
"build-preview": "PREVIEW_BUILD=1 yarn __build ",
|
||||
"vite": "vite",
|
||||
"tailwind": "yarn tailwindcss -i ./src/styles.css -o ./src/tailwind.generated.css",
|
||||
|
||||
@@ -52,6 +52,7 @@ if (!globalCal || !globalCal.q) {
|
||||
// TODO: Ideally it should be the version as per package.json and then it can be renamed to version.
|
||||
// But because it is built on local machine right now, it is much more reliable to have the commit hash.
|
||||
globalCal.fingerprint = process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT as string;
|
||||
globalCal.version = process.env.EMBED_PUBLIC_EMBED_VERSION as string;
|
||||
globalCal.__css = allCss;
|
||||
document.head.appendChild(document.createElement("style")).innerHTML = css;
|
||||
|
||||
@@ -810,6 +811,7 @@ export interface GlobalCalWithoutNs {
|
||||
instance?: Cal;
|
||||
__css?: string;
|
||||
fingerprint?: string;
|
||||
version?: string;
|
||||
__logQueue?: unknown[];
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ if (!bookerUrl || !embedLibUrl) {
|
||||
})(window, embedLibUrl, "init");
|
||||
const previewWindow = window;
|
||||
previewWindow.Cal.fingerprint = process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT as string;
|
||||
previewWindow.Cal.version = process.env.EMBED_PUBLIC_EMBED_VERSION as string;
|
||||
|
||||
previewWindow.Cal("init", {
|
||||
origin: bookerUrl,
|
||||
|
||||
@@ -13,6 +13,7 @@ module.exports = defineConfig((configEnv) => {
|
||||
plugins: [
|
||||
EnvironmentPlugin({
|
||||
EMBED_PUBLIC_EMBED_FINGER_PRINT: embedCoreEnvVars.EMBED_PUBLIC_EMBED_FINGER_PRINT,
|
||||
EMBED_PUBLIC_EMBED_VERSION: embedCoreEnvVars.EMBED_PUBLIC_EMBED_VERSION,
|
||||
EMBED_PUBLIC_VERCEL_URL: embedCoreEnvVars.EMBED_PUBLIC_VERCEL_URL,
|
||||
EMBED_PUBLIC_WEBAPP_URL: embedCoreEnvVars.EMBED_PUBLIC_WEBAPP_URL,
|
||||
}),
|
||||
|
||||
@@ -6,6 +6,8 @@ process.env.EMBED_PUBLIC_WEBAPP_URL = process.env.NEXT_PUBLIC_WEBAPP_URL;
|
||||
process.env.EMBED_PUBLIC_EMBED_LIB_URL = process.env.NEXT_PUBLIC_EMBED_LIB_URL;
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT = process.env.NEXT_PUBLIC_EMBED_FINGER_PRINT;
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
process.env.EMBED_PUBLIC_EMBED_VERSION = process.env.NEXT_PUBLIC_EMBED_VERSION;
|
||||
|
||||
// Problem: typeof process.env.EMBED_PUBLIC_EMBED_LIB_URL is "undefined"(truthy) if process.env.NEXT_PUBLIC_EMBED_LIB_URL is undefined(falsy)
|
||||
// This is probably because environment variables are always string, so this weird automatic conversion to string happens
|
||||
@@ -30,6 +32,7 @@ const viteBaseConfig = {
|
||||
export default viteBaseConfig;
|
||||
export const embedCoreEnvVars = {
|
||||
EMBED_PUBLIC_EMBED_FINGER_PRINT: process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT ?? "",
|
||||
EMBED_PUBLIC_EMBED_VERSION: process.env.EMBED_PUBLIC_EMBED_VERSION ?? "",
|
||||
EMBED_PUBLIC_VERCEL_URL: process.env.EMBED_PUBLIC_VERCEL_URL ?? "http://localhost:3000",
|
||||
EMBED_PUBLIC_WEBAPP_URL:
|
||||
process.env.EMBED_PUBLIC_WEBAPP_URL ??
|
||||
|
||||
+2
-1
@@ -188,7 +188,7 @@
|
||||
"@calcom/embed-core#build": {
|
||||
"cache": false,
|
||||
"outputs": ["../../../apps/web/public/embed/**"],
|
||||
"env": ["EMBED_PUBLIC_VERCEL_URL", "EMBED_PUBLIC_WEBAPP_URL", "EMBED_PUBLIC_EMBED_FINGER_PRINT"]
|
||||
"env": ["EMBED_PUBLIC_VERCEL_URL", "EMBED_PUBLIC_WEBAPP_URL", "EMBED_PUBLIC_EMBED_FINGER_PRINT", "EMBED_PUBLIC_EMBED_VERSION"]
|
||||
},
|
||||
"embed-tests-update-snapshots:ci": {
|
||||
"cache": false,
|
||||
@@ -418,6 +418,7 @@
|
||||
"CLOUDFLARE_VERCEL_CNAME",
|
||||
"CLOUDFLARE_DNS",
|
||||
"EMBED_PUBLIC_EMBED_FINGER_PRINT",
|
||||
"EMBED_PUBLIC_EMBED_VERSION",
|
||||
"EMBED_PUBLIC_WEBAPP_URL",
|
||||
"EMBED_PUBLIC_VERCEL_URL",
|
||||
"NEXT_PUBLIC_ENABLE_PROFILE_SWITCHER",
|
||||
|
||||
Reference in New Issue
Block a user