diff --git a/source/elegant/.env.starter b/source/elegant/.env.starter index bf09207a..6c3bbf4d 100644 --- a/source/elegant/.env.starter +++ b/source/elegant/.env.starter @@ -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="info@elegantframework.com" -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="" \ No newline at end of file +CMS_REPOSITORY_BRANCH="main" +CMS_GITHUB_ID="" +CMS_GITHUB_SECRET="" +CMS_TOKEN_SECRET="" +CMS_REPOSITORY_SLUG="" +CMS_REPOSITORY_OWNER="" \ No newline at end of file diff --git a/source/elegant/.env.test b/source/elegant/.env.test index f6cc1e51..c5eed872 100644 --- a/source/elegant/.env.test +++ b/source/elegant/.env.test @@ -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" diff --git a/source/elegant/package-lock.json b/source/elegant/package-lock.json index 13e67966..048d0773 100644 --- a/source/elegant/package-lock.json +++ b/source/elegant/package-lock.json @@ -4386,7 +4386,7 @@ "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", - "devOptional": true + "dev": true }, "node_modules/@types/qs": { "version": "6.9.15", @@ -4404,7 +4404,7 @@ "version": "18.0.28", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.28.tgz", "integrity": "sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==", - "devOptional": true, + "dev": true, "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -4426,7 +4426,7 @@ "version": "18.2.6", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.6.tgz", "integrity": "sha512-2et4PDvg6PVCyS7fuTc4gPoksV58bW0RwSxWKcPRcHZf0PRUGq03TKcD/rUHe3azfV6/5/biUBJw+HhCQjaP0A==", - "devOptional": true, + "dev": true, "dependencies": { "@types/react": "*" } @@ -4444,7 +4444,7 @@ "version": "0.16.2", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", - "devOptional": true + "dev": true }, "node_modules/@types/send": { "version": "0.17.4", @@ -6121,7 +6121,8 @@ "node_modules/csstype": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz", - "integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==" + "integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==", + "dev": true }, "node_modules/cypress": { "version": "13.6.3", diff --git a/source/elegant/src/config/Admin.ts b/source/elegant/src/config/Admin.ts index 3d676dc0..81ba0036 100644 --- a/source/elegant/src/config/Admin.ts +++ b/source/elegant/src/config/Admin.ts @@ -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', /* |-------------------------------------------------------------------------- @@ -35,7 +35,7 @@ const AdminConfig = () => { | | */ - 'cms_github_id': process.env.NEXT_PUBLIC_CMS_GITHUB_ID || '', + 'cms_github_id': process.env.CMS_GITHUB_ID || '', /* |-------------------------------------------------------------------------- @@ -46,7 +46,7 @@ const AdminConfig = () => { | | */ - 'cms_github_secret': process.env.NEXT_PUBLIC_CMS_GITHUB_SECRET || '', + 'cms_github_secret': process.env.CMS_GITHUB_SECRET || '', /* |-------------------------------------------------------------------------- @@ -60,7 +60,7 @@ const AdminConfig = () => { | | */ - 'cms_token_secret': process.env.NEXT_PUBLIC_CMS_TOKEN_SECRET || '', + 'cms_token_secret': process.env.CMS_TOKEN_SECRET || '', /* |-------------------------------------------------------------------------- @@ -72,7 +72,7 @@ const AdminConfig = () => { | | */ - 'cms_repository_slug': process.env.NEXT_PUBLIC_CMS_REPOSITORY_SLUG || '', + 'cms_repository_slug': process.env.CMS_REPOSITORY_SLUG || '', /* |-------------------------------------------------------------------------- @@ -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 || '', /* |-------------------------------------------------------------------------- diff --git a/source/elegant/src/config/__tests__/Admin.test.ts b/source/elegant/src/config/__tests__/Admin.test.ts index 33b5ba5d..43487a62 100644 --- a/source/elegant/src/config/__tests__/Admin.test.ts +++ b/source/elegant/src/config/__tests__/Admin.test.ts @@ -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(""); }); diff --git a/source/elegant/src/utils/envVarsCheck.ts b/source/elegant/src/utils/envVarsCheck.ts index 03ad8232..b8b50cb0 100644 --- a/source/elegant/src/utils/envVarsCheck.ts +++ b/source/elegant/src/utils/envVarsCheck.ts @@ -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, @@ -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]) => {