Skip to content

Commit

Permalink
Update cms env vars (#568)
Browse files Browse the repository at this point in the history
* Update the env vars

I have updated the cms env vars from "PUBLIC_" to not using the public prefix as recommended by Vercel

* Revert "Bump @testing-library/jest-dom and @types/testing-library__jest-dom (#481)"

This reverts commit 2f0186c.

* Update vars
  • Loading branch information
Bowens20832 authored Oct 13, 2024
1 parent 379c81c commit 482c23c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
12 changes: 6 additions & 6 deletions source/elegant/.env.starter
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ NEXT_PUBLIC_APP_URL="http://localhost:3000"
NEXT_PUBLIC_APP_REPOSITORY="https://github.com/elegantframework/elegant"
NEXT_PUBLIC_APP_TYPE="Organization"
NEXT_PUBLIC_CONTACT_EMAIL="[email protected]"
NEXT_PUBLIC_CMS_REPOSITORY_BRANCH="main"
NEXT_PUBLIC_CMS_GITHUB_ID=""
NEXT_PUBLIC_CMS_GITHUB_SECRET=""
NEXT_PUBLIC_CMS_TOKEN_SECRET=""
NEXT_PUBLIC_CMS_REPOSITORY_SLUG=""
NEXT_PUBLIC_CMS_REPOSITORY_OWNER=""
CMS_REPOSITORY_BRANCH="main"
CMS_GITHUB_ID=""
CMS_GITHUB_SECRET=""
CMS_TOKEN_SECRET=""
CMS_REPOSITORY_SLUG=""
CMS_REPOSITORY_OWNER=""
12 changes: 6 additions & 6 deletions source/elegant/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ NEXT_PUBLIC_APP_YOUTUBE_URL=""
NEXT_PUBLIC_APP_LINKEDIN_URL=""

NEXT_PUBLIC_CMS_NAME="Testing"
NEXT_PUBLIC_CMS_REPOSITORY_BRANCH="unit/test"
CMS_REPOSITORY_BRANCH="unit/test"

NEXT_PUBLIC_CMS_GITHUB_ID="9765ab0581dddb2e73d22"
NEXT_PUBLIC_CMS_GITHUB_SECRET="2vd9as9dsa363889cdsjnadskbs3ce4ddd27c8ad31aba1c02"
NEXT_PUBLIC_CMS_TOKEN_SECRET="0ae65b8489609dnjkasdnaskndkasde83c46dawvf79ea9bd1edc77f81599nef"
NEXT_PUBLIC_CMS_REPOSITORY_SLUG="unit-test-repo"
NEXT_PUBLIC_CMS_REPOSITORY_OWNER="testerowner"
CMS_GITHUB_ID="9765ab0581dddb2e73d22"
CMS_GITHUB_SECRET="2vd9as9dsa363889cdsjnadskbs3ce4ddd27c8ad31aba1c02"
CMS_TOKEN_SECRET="0ae65b8489609dnjkasdnaskndkasde83c46dawvf79ea9bd1edc77f81599nef"
CMS_REPOSITORY_SLUG="unit-test-repo"
CMS_REPOSITORY_OWNER="testerowner"

NEXT_PUBLIC_CMS_CONTENT_PATH="src/test/pages"
NEXT_PUBLIC_CMS_MONOREPO_PATH="hello/world"
Expand Down
11 changes: 6 additions & 5 deletions source/elegant/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions source/elegant/src/config/Admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const AdminConfig = () => {
|
|
*/
'cms_repository_branch': process.env.NEXT_PUBLIC_CMS_REPOSITORY_BRANCH || 'main',
'cms_repository_branch': process.env.CMS_REPOSITORY_BRANCH || 'main',

/*
|--------------------------------------------------------------------------
Expand All @@ -35,7 +35,7 @@ const AdminConfig = () => {
|
|
*/
'cms_github_id': process.env.NEXT_PUBLIC_CMS_GITHUB_ID || '',
'cms_github_id': process.env.CMS_GITHUB_ID || '',

/*
|--------------------------------------------------------------------------
Expand All @@ -46,7 +46,7 @@ const AdminConfig = () => {
|
|
*/
'cms_github_secret': process.env.NEXT_PUBLIC_CMS_GITHUB_SECRET || '',
'cms_github_secret': process.env.CMS_GITHUB_SECRET || '',

/*
|--------------------------------------------------------------------------
Expand All @@ -60,7 +60,7 @@ const AdminConfig = () => {
|
|
*/
'cms_token_secret': process.env.NEXT_PUBLIC_CMS_TOKEN_SECRET || '',
'cms_token_secret': process.env.CMS_TOKEN_SECRET || '',

/*
|--------------------------------------------------------------------------
Expand All @@ -72,7 +72,7 @@ const AdminConfig = () => {
|
|
*/
'cms_repository_slug': process.env.NEXT_PUBLIC_CMS_REPOSITORY_SLUG || '',
'cms_repository_slug': process.env.CMS_REPOSITORY_SLUG || '',

/*
|--------------------------------------------------------------------------
Expand All @@ -83,7 +83,7 @@ const AdminConfig = () => {
| If the repository owner is not set, the GitHub username of the logged in account will be used.
|
*/
'cms_repository_owner': process.env.NEXT_PUBLIC_CMS_REPOSITORY_OWNER || '',
'cms_repository_owner': process.env.CMS_REPOSITORY_OWNER || '',

/*
|--------------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions source/elegant/src/config/__tests__/Admin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,45 @@ describe('Admin Config', () => {
it('returns a proper CMS repository branch', () => {
expect(AdminConfig().cms_repository_branch).toBe("unit/test");

process.env.NEXT_PUBLIC_CMS_REPOSITORY_BRANCH = undefined;
process.env.CMS_REPOSITORY_BRANCH = undefined;
expect(AdminConfig().cms_repository_branch).toBe("main");

process.env.NEXT_PUBLIC_CMS_REPOSITORY_BRANCH = "hello/world";
process.env.CMS_REPOSITORY_BRANCH = "hello/world";
expect(AdminConfig().cms_repository_branch).toBe("hello/world");
});

it('returns a proper CMS github id', () => {
expect(AdminConfig().cms_github_id).toBe("9765ab0581dddb2e73d22");

process.env.NEXT_PUBLIC_CMS_GITHUB_ID = undefined;
process.env.CMS_GITHUB_ID = undefined;
expect(AdminConfig().cms_github_id).toBe("");
});

it('returns a proper CMS github secret', () => {
expect(AdminConfig().cms_github_secret).toBe("2vd9as9dsa363889cdsjnadskbs3ce4ddd27c8ad31aba1c02");

process.env.NEXT_PUBLIC_CMS_GITHUB_SECRET = undefined;
process.env.CMS_GITHUB_SECRET = undefined;
expect(AdminConfig().cms_github_secret).toBe("");
});

it('returns a proper CMS token secret', () => {
expect(AdminConfig().cms_token_secret).toBe("0ae65b8489609dnjkasdnaskndkasde83c46dawvf79ea9bd1edc77f81599nef");

process.env.NEXT_PUBLIC_CMS_TOKEN_SECRET = undefined;
process.env.CMS_TOKEN_SECRET = undefined;
expect(AdminConfig().cms_token_secret).toBe("");
});

it('returns a proper CMS repository slug', () => {
expect(AdminConfig().cms_repository_slug).toBe("unit-test-repo");

process.env.NEXT_PUBLIC_CMS_REPOSITORY_SLUG = undefined;
process.env.CMS_REPOSITORY_SLUG = undefined;
expect(AdminConfig().cms_repository_slug).toBe("");
});

it('returns a proper CMS repository owner', () => {
expect(AdminConfig().cms_repository_owner).toBe("testerowner");

process.env.NEXT_PUBLIC_CMS_REPOSITORY_OWNER = undefined;
process.env.CMS_REPOSITORY_OWNER = undefined;
expect(AdminConfig().cms_repository_owner).toBe("");
});

Expand Down
14 changes: 7 additions & 7 deletions source/elegant/src/utils/envVarsCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ type EnvVarsObjType = {

const initialEnvVars: EnvVarsType = {
required: {
NEXT_PUBLIC_CMS_GITHUB_ID: false,
NEXT_PUBLIC_CMS_GITHUB_SECRET: false,
NEXT_PUBLIC_CMS_TOKEN_SECRET: false,
NEXT_PUBLIC_CMS_REPOSITORY_SLUG: false,
NEXT_PUBLIC_CMS_REPOSITORY_OWNER: false
CMS_GITHUB_ID: false,
CMS_GITHUB_SECRET: false,
CMS_TOKEN_SECRET: false,
CMS_REPOSITORY_SLUG: false,
CMS_REPOSITORY_OWNER: false
},
optional: {
NEXT_PUBLIC_CMS_CONTENT_PATH: false,
Expand All @@ -39,11 +39,11 @@ export const envVars = (function () {
// The repo slug takes precedence over VERCEL_GIT_REPO_SLUG,
// if both are empty, then we default to asking for the repo slug
if (Config('admin.cms_repository_slug')) {
initialEnvVars.required.NEXT_PUBLIC_CMS_REPOSITORY_SLUG = true
initialEnvVars.required.CMS_REPOSITORY_SLUG = true
} else if (process.env.VERCEL_GIT_REPO_SLUG) {
initialEnvVars.required.VERCEL_GIT_REPO_SLUG = true
} else {
initialEnvVars.required.NEXT_PUBLIC_CMS_REPOSITORY_SLUG = false
initialEnvVars.required.CMS_REPOSITORY_SLUG = false
}

Object.entries(initialEnvVars.required).forEach(([key]) => {
Expand Down

0 comments on commit 482c23c

Please sign in to comment.