The Dotenv Refactor (#2275)

* dotenv refactoring

* dotenv fixes

* Env variables cleanup

* Updates e2e variables

* Moves environment file to types

* Removes conflicting configs

* Readds missing variables

* Fixes

* More fixes

* Update .env.example

* Update yarn.lock

* Update turbo.json

* Fixes e2e

* Temp fix

* disables cache for lint

* Please work

* I'm getting desperate here.

* Matches node versions

* Take 2

* Revert "Take 2"

This reverts commit a735f47f2325c2040168e0cd99dea0fc357a791f.

* Update .env.example
This commit is contained in:
Omar López authored and GitHub committed 2022-03-25 17:39:38 -07:00
1 parent 2d7e1ccc05
commit ec58a9dd70
42 files changed
+498 -243

No files matched your search

@@ -1,4 +0,0 @@
# Place these on `apps/web/.env`
# @see https://github.com/calcom/cal.com/#Obtaining-Microsoft-Graph-Client-ID-and-Secret
MS_GRAPH_CLIENT_CLIENT_ID=
MS_GRAPH_CLIENT_CLIENT_SECRET=
@@ -12,7 +12,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return;
}
const return_url = `${process.env.BASE_URL}/settings/billing`;
const return_url = `${process.env.NEXT_PUBLIC_WEBAPP_URL}/settings/billing`;
const stripeSession = await stripe.billingPortal.sessions.create({
customer: customerId,
return_url,
@@ -1,4 +0,0 @@
# Place these on `apps/web/.env`
# @see https://github.com/calcom/cal.com/#obtaining-zoom-client-id-and-secret
ZOOM_CLIENT_ID=
ZOOM_CLIENT_SECRET=
+6 -3
View File
@@ -1,6 +1,9 @@
export const BASE_URL = process.env.BASE_URL || `https://${process.env.VERCEL_URL}`;
export const WEBSITE_URL = process.env.NEXT_PUBLIC_APP_URL || "https://cal.com";
export const WEBAPP_URL = process.env.NEXT_PUBLIC_WEBAPP_URL || `https://${process.env.VERCEL_URL}`;
/** @deprecated use `WEBAPP_URL` */
export const BASE_URL = WEBAPP_URL;
export const WEBSITE_URL = process.env.NEXT_PUBLIC_WEBSITE_URL || "https://cal.com";
export const IS_PRODUCTION = process.env.NODE_ENV === "production";
export const TRIAL_LIMIT_DAYS = 14;
export const HOSTED_CAL_FEATURES = process.env.HOSTED_CAL_FEATURES || BASE_URL === "https://app.cal.com";
export const NEXT_PUBLIC_BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || `https://${process.env.VERCEL_URL}`;
/** @deprecated use `WEBAPP_URL` */
export const NEXT_PUBLIC_BASE_URL = process.env.NEXT_PUBLIC_WEBAPP_URL || `https://${process.env.VERCEL_URL}`;
+8 -4
View File
@@ -5,6 +5,8 @@ import { uuid } from "short-uuid";
import { hashPassword } from "@calcom/lib/auth";
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability";
require("dotenv").config({ path: "../../.env" });
const prisma = new PrismaClient();
async function createUserAndEventType(opts: {
@@ -51,7 +53,7 @@ async function createUserAndEventType(opts: {
});
console.log(
`👤 Upserted '${opts.user.username}' with email "${opts.user.email}" & password "${opts.user.password}". Booking page 👉 ${process.env.BASE_URL}/${opts.user.username}`
`👤 Upserted '${opts.user.username}' with email "${opts.user.email}" & password "${opts.user.password}". Booking page 👉 ${process.env.NEXT_PUBLIC_WEBAPP_URL}/${opts.user.username}`
);
for (const eventTypeInput of opts.eventTypes) {
@@ -75,7 +77,7 @@ async function createUserAndEventType(opts: {
if (eventType) {
console.log(
`\t📆 Event type ${eventTypeData.slug} already seems seeded - ${process.env.BASE_URL}/${user.username}/${eventTypeData.slug}`
`\t📆 Event type ${eventTypeData.slug} already seems seeded - ${process.env.NEXT_PUBLIC_WEBAPP_URL}/${user.username}/${eventTypeData.slug}`
);
continue;
}
@@ -84,7 +86,7 @@ async function createUserAndEventType(opts: {
});
console.log(
`\t📆 Event type ${eventTypeData.slug}, length ${eventTypeData.length}min - ${process.env.BASE_URL}/${user.username}/${eventTypeData.slug}`
`\t📆 Event type ${eventTypeData.slug}, length ${eventTypeData.length}min - ${process.env.NEXT_PUBLIC_WEBAPP_URL}/${user.username}/${eventTypeData.slug}`
);
for (const bookingInput of bookingInputs) {
await prisma.booking.create({
@@ -146,7 +148,9 @@ async function createTeamAndAddUsers(
return;
}
console.log(`🏢 Created team '${teamInput.name}' - ${process.env.BASE_URL}/team/${team.slug}`);
console.log(
`🏢 Created team '${teamInput.name}' - ${process.env.NEXT_PUBLIC_WEBAPP_URL}/team/${team.slug}`
);
for (const user of users) {
const { role = MembershipRole.OWNER, id, username } = user;
+1 -1
View File
@@ -29,7 +29,7 @@ export function createPaymentLink(opts: {
}): string {
const { paymentUid, name, date, absolute = true } = opts;
let link = "";
if (absolute) link = process.env.NEXT_PUBLIC_APP_URL!;
if (absolute) link = process.env.NEXT_PUBLIC_WEBSITE_URL!;
const query = stringify({ date, name });
return link + `/payment/${paymentUid}?${query}`;
}
+2 -2
View File
@@ -241,8 +241,8 @@ async function createCheckoutSession(
payment_method_types: ["card"],
customer: customerId,
line_items,
success_url: `${process.env.NEXT_PUBLIC_APP_URL}/api/teams/${teamId}/upgrade?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/`,
success_url: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/api/teams/${teamId}/upgrade?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/`,
allow_promotion_codes: true,
};
+62
View File
@@ -0,0 +1,62 @@
declare namespace NodeJS {
interface ProcessEnv {
/**
* Set this value to 'agree' to accept our license:
* LICENSE: https://github.com/calendso/calendso/blob/main/LICENSE
*
* Summary of terms:
* - The codebase has to stay open source, whether it was modified or not
* - You can not repackage or sell the codebase
* - Acquire a commercial license to remove these terms by visiting: cal.com/sales
**/
readonly NEXT_PUBLIC_LICENSE_CONSENT: "agree" | undefined;
readonly CALENDSO_ENCRYPTION_KEY: string | undefined;
readonly DATABASE_URL: string | undefined;
readonly GOOGLE_API_CREDENTIALS: string | undefined;
/** @deprecated use `NEXT_PUBLIC_WEBAPP_URL` */
readonly BASE_URL: string | undefined;
/** @deprecated use `NEXT_PUBLIC_WEBAPP_URL` */
readonly NEXT_PUBLIC_BASE_URL: string | undefined;
/** @deprecated use `NEXT_PUBLIC_WEBSITE_URL` */
readonly NEXT_PUBLIC_APP_URL: string | undefined;
readonly JWT_SECRET: string | undefined;
readonly NEXT_PUBLIC_TELEMETRY_KEY: string | undefined;
readonly MS_GRAPH_CLIENT_ID: string | undefined;
readonly MS_GRAPH_CLIENT_SECRET: string | undefined;
readonly ZOOM_CLIENT_ID: string | undefined;
readonly ZOOM_CLIENT_SECRET: string | undefined;
readonly EMAIL_FROM: string | undefined;
readonly EMAIL_SERVER_HOST: string | undefined;
readonly EMAIL_SERVER_PORT: string | undefined;
readonly EMAIL_SERVER_USER: string | undefined;
readonly EMAIL_SERVER_PASSWORD: string | undefined;
readonly CRON_API_KEY: string | undefined;
readonly NEXT_PUBLIC_STRIPE_PUBLIC_KEY: string | undefined;
readonly STRIPE_PRIVATE_KEY: string | undefined;
readonly STRIPE_CLIENT_ID: string | undefined;
readonly STRIPE_WEBHOOK_SECRET: string | undefined;
readonly PAYMENT_FEE_PERCENTAGE: number | undefined;
readonly PAYMENT_FEE_FIXED: number | undefined;
readonly NEXT_PUBLIC_INTERCOM_APP_ID: string | undefined;
readonly TANDEM_CLIENT_ID: string | undefined;
readonly TANDEM_CLIENT_SECRET: string | undefined;
readonly TANDEM_BASE_URL: string | undefined;
readonly WEBSITE_BASE_URL: string | undefined;
/** @deprecated use `NEXT_PUBLIC_WEBSITE_URL` */
readonly NEXT_PUBLIC_WEBSITE_BASE_URL: string;
readonly NEXT_PUBLIC_WEBSITE_URL: string;
readonly APP_BASE_URL: string | undefined;
/** @deprecated use `NEXT_PUBLIC_WEBAPP_URL` */
readonly NEXT_PUBLIC_APP_BASE_URL: string;
readonly NEXT_PUBLIC_WEBAPP_URL: string;
/** The Environment that the app is deployed an running on. */
readonly VERCEL_ENV: "production" | "preview" | "development" | undefined;
/** The URL of the deployment. Example: my-site-7q03y4pi5.vercel.app. */
readonly VERCEL_URL: string | undefined;
/**
* This is used so we can bypass emails in auth flows for E2E testing.
* Set it to "1" if you need to run E2E tests locally
**/
readonly NEXT_PUBLIC_IS_E2E: 1 | undefined;
}
}