Skip to content

Commit

Permalink
feat: improve boolean coercion of SKIP_ENV_VALIDATION (#1358)
Browse files Browse the repository at this point in the history
* fix: incorrect behavior of SKIP_ENV_VALIDATION

* improve boolean coercion of SKIP_ENV_VALIDATION

* changesets

---------

Co-authored-by: Pichaya Puttekulangkura <[email protected]>
  • Loading branch information
juliusmarminge and mickyngub committed Apr 14, 2023
1 parent c48b38f commit 1a8a97e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .changeset/blue-walls-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"create-t3-app": minor
---

improve boolean coercion of `SKIP_ENV_VALIDATION` environment variable

If defined, "0" and "false" are now considered falsey values, all other values are considered truthy.
10 changes: 5 additions & 5 deletions cli/template/base/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
* This is especially useful for Docker builds.
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
!process.env.SKIP_ENV_VALIDATION && (await import("./src/env.mjs"));
await import("./src/env.mjs");

/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,

/**
* If you have the "experimental: { appDir: true }" setting enabled, then you
* must comment the below `i18n` config out.
* If you have `experimental: { appDir: true }` set, then you must comment the below `i18n` config
* out.
*
* @see https://github.com/vercel/next.js/issues/41980
*/
Expand Down
6 changes: 5 additions & 1 deletion cli/template/base/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ const merged = server.merge(client);

let env = /** @type {MergedOutput} */ (process.env);

if (!!process.env.SKIP_ENV_VALIDATION == false) {
const skip =
!!process.env.SKIP_ENV_VALIDATION &&
process.env.SKIP_ENV_VALIDATION !== "false" &&
process.env.SKIP_ENV_VALIDATION !== "0";
if (!skip) {
const isServer = typeof window === "undefined";

const parsed = /** @type {MergedSafeParseReturn} */ (
Expand Down
6 changes: 5 additions & 1 deletion cli/template/extras/src/env/with-auth-prisma.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ const merged = server.merge(client);

let env = /** @type {MergedOutput} */ (process.env);

if (!!process.env.SKIP_ENV_VALIDATION == false) {
const skip =
!!process.env.SKIP_ENV_VALIDATION &&
process.env.SKIP_ENV_VALIDATION !== "false" &&
process.env.SKIP_ENV_VALIDATION !== "0";
if (!skip) {
const isServer = typeof window === "undefined";

const parsed = /** @type {MergedSafeParseReturn} */ (
Expand Down
6 changes: 5 additions & 1 deletion cli/template/extras/src/env/with-auth.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ const merged = server.merge(client);

let env = /** @type {MergedOutput} */ (process.env);

if (!!process.env.SKIP_ENV_VALIDATION == false) {
const skip =
!!process.env.SKIP_ENV_VALIDATION &&
process.env.SKIP_ENV_VALIDATION !== "false" &&
process.env.SKIP_ENV_VALIDATION !== "0";
if (!skip) {
const isServer = typeof window === "undefined";

const parsed = /** @type {MergedSafeParseReturn} */ (
Expand Down
6 changes: 5 additions & 1 deletion cli/template/extras/src/env/with-prisma.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ const merged = server.merge(client);

let env = /** @type {MergedOutput} */ (process.env);

if (!!process.env.SKIP_ENV_VALIDATION == false) {
const skip =
!!process.env.SKIP_ENV_VALIDATION &&
process.env.SKIP_ENV_VALIDATION !== "false" &&
process.env.SKIP_ENV_VALIDATION !== "0";
if (!skip) {
const isServer = typeof window === "undefined";

const parsed = /** @type {MergedSafeParseReturn} */ (
Expand Down

1 comment on commit 1a8a97e

@vercel
Copy link

@vercel vercel bot commented on 1a8a97e Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.