From 5fb6980c4435d05a6d3d31ae4a57aaf4940f0abd Mon Sep 17 00:00:00 2001 From: Rishabh Poddar Date: Thu, 3 Mar 2022 21:59:56 +0530 Subject: [PATCH 1/2] Update supertokens demo app (#35007) New version of supertokens-auth-react. Co-authored-by: Bhumil Sarvaiya <21988812+bhumilsarvaiya@users.noreply.github.com> Co-authored-by: Joel Coutinho <6310783+jscyo@users.noreply.github.com> --- examples/with-supertokens/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-supertokens/package.json b/examples/with-supertokens/package.json index 5f4e2067c308..ae96a6debfd8 100644 --- a/examples/with-supertokens/package.json +++ b/examples/with-supertokens/package.json @@ -9,7 +9,7 @@ "next": "latest", "react": "^17.0.1", "react-dom": "^17.0.1", - "supertokens-auth-react": "^0.18.0", + "supertokens-auth-react": "^0.19.0", "supertokens-node": "^9.0.0" } } From 728d82663c9c65b12c22c02de815297c56a3ff53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 3 Mar 2022 17:52:20 +0100 Subject: [PATCH 2/2] feat: allow dotenv default expansion (#34765) We currently use `dotenv-expand@5` in `@next/env`, which does not support default expansion. It was added in v6 (https://github.com/motdotla/dotenv-expand/pull/39). Upgrading to the latest version of `dotenv-expand` and fixing an import, the added test passed. Fixes #34718 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` --- packages/next-env/index.ts | 2 +- packages/next-env/package.json | 2 +- .../dotenv-default-expansion/index.test.ts | 32 +++++++++++++++++++ yarn.lock | 9 +++--- 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 test/development/dotenv-default-expansion/index.test.ts diff --git a/packages/next-env/index.ts b/packages/next-env/index.ts index 343e80251879..97df9677629d 100644 --- a/packages/next-env/index.ts +++ b/packages/next-env/index.ts @@ -2,7 +2,7 @@ import * as fs from 'fs' import * as path from 'path' import * as dotenv from 'dotenv' -import dotenvExpand from 'dotenv-expand' +import { expand as dotenvExpand } from 'dotenv-expand' export type Env = { [key: string]: string } export type LoadedEnvFiles = Array<{ diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 9e9540c9ae1e..5bf5140b5425 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -31,6 +31,6 @@ "devDependencies": { "@vercel/ncc": "0.33.1", "dotenv": "10.0.0", - "dotenv-expand": "5.1.0" + "dotenv-expand": "8.0.1" } } diff --git a/test/development/dotenv-default-expansion/index.test.ts b/test/development/dotenv-default-expansion/index.test.ts new file mode 100644 index 000000000000..01b6cd0f9bc3 --- /dev/null +++ b/test/development/dotenv-default-expansion/index.test.ts @@ -0,0 +1,32 @@ +import { createNext } from 'e2e-utils' +import { NextInstance } from 'test/lib/next-modes/base' +import webdriver from 'next-webdriver' + +describe('Dotenv default expansion', () => { + let next: NextInstance + + beforeAll(async () => { + next = await createNext({ + files: { + 'pages/index.js': ` + export default function Page() { + return

{process.env.NEXT_PUBLIC_TEST}

+ } + `, + '.env': ` + NEXT_PUBLIC_TEST=\${MISSING_KEY:-default} + `, + }, + dependencies: {}, + }) + }) + afterAll(() => next.destroy()) + + it('should work', async () => { + const browser = await webdriver(next.appPort, '/') + const text = await browser.elementByCss('p').text() + expect(text).toBe('default') + + await browser.close() + }) +}) diff --git a/yarn.lock b/yarn.lock index 53743dacc843..935c13e59280 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9118,10 +9118,10 @@ dot-prop@^6.0.1: dependencies: is-obj "^2.0.0" -dotenv-expand@5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0" - integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA== +dotenv-expand@8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-8.0.1.tgz#332aa17c14b12e28e2e230f8d183eecc1c014fdc" + integrity sha512-j/Ih7bIERDR5PzI89Zu8ayd3tXZ6E3dbY0ljQ9Db0K87qBO8zdLsi2dIvDHMWtjC3Yxb8XixOTHAtia0fDHRpg== dotenv@10.0.0: version "10.0.0" @@ -14663,6 +14663,7 @@ minipass-fetch@^1.3.0, minipass-fetch@^1.3.2: resolved "https://registry.yarnpkg.com/minipass-fetch/-/minipass-fetch-1.3.3.tgz#34c7cea038c817a8658461bf35174551dce17a0a" integrity sha512-akCrLDWfbdAWkMLBxJEeWTdNsjML+dt5YgOI4gJ53vuO0vrmYQkUPxa6j6V65s9CcePIr2SSWqjT2EcrNseryQ== dependencies: + encoding "^0.1.12" minipass "^3.1.0" minipass-sized "^1.0.3" minizlib "^2.0.0"