From 5387bb3ca50b53cdba6ae8d7496e893d851c4a83 Mon Sep 17 00:00:00 2001 From: Michael Hudson Nkotagu Date: Tue, 16 Jul 2024 12:17:08 +0300 Subject: [PATCH 1/7] fix: Remove typographyProps in Initiative Heading --- apps/roboshield/src/components/Footer/Footer.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/roboshield/src/components/Footer/Footer.tsx b/apps/roboshield/src/components/Footer/Footer.tsx index 8a3ab40bf..e3bfc13e3 100644 --- a/apps/roboshield/src/components/Footer/Footer.tsx +++ b/apps/roboshield/src/components/Footer/Footer.tsx @@ -96,9 +96,7 @@ export default function Footer({ sx={{ height: "113px", mt: { xs: "52px", md: 0 } }} > {initiative?.title} From f2161ec90fa240b6086149ac7dc0b036707f9063 Mon Sep 17 00:00:00 2001 From: Michael Hudson Nkotagu Date: Tue, 16 Jul 2024 13:24:00 +0300 Subject: [PATCH 2/7] fix: Use correct number of parameters to supress forwardRef warnings --- .../components/TwoToneBackground/TwoToneBackground.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/roboshield/src/components/TwoToneBackground/TwoToneBackground.tsx b/apps/roboshield/src/components/TwoToneBackground/TwoToneBackground.tsx index a9fab0f11..2cea4c64e 100644 --- a/apps/roboshield/src/components/TwoToneBackground/TwoToneBackground.tsx +++ b/apps/roboshield/src/components/TwoToneBackground/TwoToneBackground.tsx @@ -45,10 +45,10 @@ interface Props { sx: any; } -const TwoToneBackground = React.forwardRef(function TwoToneBackground({ - children, - ...props -}: Props) { +const TwoToneBackground = React.forwardRef(function TwoToneBackground( + { children, ...props }: Props, + _ref, +) { return {children}; }); From 87b39067356ecf53f8fc5769d634354f43461d1a Mon Sep 17 00:00:00 2001 From: Michael Hudson Nkotagu Date: Tue, 16 Jul 2024 16:13:48 +0300 Subject: [PATCH 3/7] chore: Apply fixes to issues causing build failure --- apps/roboshield/payload-types.ts | 72 ++++++++++-------------- apps/roboshield/payload.config.ts | 3 + apps/roboshield/src/lib/payload/index.ts | 12 ++-- 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/apps/roboshield/payload-types.ts b/apps/roboshield/payload-types.ts index 6928f0159..18b4b04eb 100644 --- a/apps/roboshield/payload-types.ts +++ b/apps/roboshield/payload-types.ts @@ -11,11 +11,11 @@ export interface Config { media: Media; pages: Page; users: User; - "payload-preferences": PayloadPreference; - "payload-migrations": PayloadMigration; + 'payload-preferences': PayloadPreference; + 'payload-migrations': PayloadMigration; }; globals: { - "settings-site": SettingsSite; + 'settings-site': SettingsSite; }; } /** @@ -53,7 +53,7 @@ export interface Page { subtitle: string; id?: string | null; blockName?: string | null; - blockType: "page-header"; + blockType: 'page-header'; } | SiteHero | { @@ -65,30 +65,30 @@ export interface Page { }[]; id?: string | null; blockName?: string | null; - blockType: "richtext"; + blockType: 'richtext'; } | { image: string | Media; id?: string | null; blockName?: string | null; - blockType: "mediaBlock"; + blockType: 'mediaBlock'; } | { externalEmbedFields?: { - embedType?: ("url" | "code") | null; + embedType?: ('url' | 'code') | null; url?: string | null; caption?: string | null; code?: string | null; }; id?: string | null; blockName?: string | null; - blockType: "externalEmbed"; + blockType: 'externalEmbed'; } )[] | null; id?: string | null; blockName?: string | null; - blockType: "content"; + blockType: 'content'; } | { title: string; @@ -105,7 +105,7 @@ export interface Page { | null; id?: string | null; blockName?: string | null; - blockType: "statistics"; + blockType: 'statistics'; } | { steps?: @@ -124,7 +124,7 @@ export interface Page { fetch: string; id?: string | null; blockName?: string | null; - blockType: "existing-robots-txt"; + blockType: 'existing-robots-txt'; } | { title: string; @@ -147,7 +147,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: "delays"; + blockType: 'delays'; } | { title: string; @@ -170,7 +170,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: "paths"; + blockType: 'paths'; } | { title: string; @@ -189,7 +189,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: "block-bots"; + blockType: 'block-bots'; } | { title: string; @@ -201,7 +201,7 @@ export interface Page { placeholder: string; id?: string | null; blockName?: string | null; - blockType: "site-maps"; + blockType: 'site-maps'; } | { title: string; @@ -213,7 +213,7 @@ export interface Page { placeholder: string; id?: string | null; blockName?: string | null; - blockType: "finish"; + blockType: 'finish'; } )[] | null; @@ -227,7 +227,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: "robots-txt-generator"; + blockType: 'robots-txt-generator'; } )[] | null; @@ -247,7 +247,7 @@ export interface Page { | null; updatedAt: string; createdAt: string; - _status?: ("draft" | "published") | null; + _status?: ('draft' | 'published') | null; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -256,7 +256,7 @@ export interface Page { export interface SiteHero { heroHeaders?: | { - headingType?: ("largeHeading" | "subHeading" | "rotatingText") | null; + headingType?: ('largeHeading' | 'subHeading' | 'rotatingText') | null; title?: string | null; id?: string | null; }[] @@ -267,7 +267,7 @@ export interface SiteHero { heroCallToAction?: string | null; id?: string | null; blockName?: string | null; - blockType: "page-hero"; + blockType: 'page-hero'; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -277,7 +277,7 @@ export interface User { id: string; firstName: string; lastName: string; - roles: ("admin" | "editor")[]; + roles: ('admin' | 'editor')[]; updatedAt: string; createdAt: string; email: string; @@ -298,7 +298,7 @@ export interface User { export interface PayloadPreference { id: string; user: { - relationTo: "users"; + relationTo: 'users'; value: string | User; }; key?: string | null; @@ -341,9 +341,9 @@ export interface SettingsSite { menus?: | { label: string; - linkType?: ("custom" | "internal") | null; + linkType?: ('custom' | 'internal') | null; doc?: { - relationTo: "pages"; + relationTo: 'pages'; value: string | Page; } | null; url?: string | null; @@ -351,17 +351,15 @@ export interface SettingsSite { id?: string | null; }[] | null; - connect?: - | ("Facebook" | "Twitter" | "Instagram" | "Linkedin" | "Github" | "Slack") - | null; + connect?: ('Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack') | null; }; secondaryNavigation?: { menus?: | { label: string; - linkType?: ("custom" | "internal") | null; + linkType?: ('custom' | 'internal') | null; doc?: { - relationTo: "pages"; + relationTo: 'pages'; value: string | Page; } | null; url?: string | null; @@ -374,13 +372,7 @@ export interface SettingsSite { title: string; links?: | { - platform: - | "Facebook" - | "Twitter" - | "Instagram" - | "Linkedin" - | "Github" - | "Slack"; + platform: 'Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack'; url: string; id?: string | null; }[] @@ -400,9 +392,9 @@ export interface SettingsSite { name: string; logo: string | Media; label: string; - linkType?: ("custom" | "internal") | null; + linkType?: ('custom' | 'internal') | null; doc?: { - relationTo: "pages"; + relationTo: 'pages'; value: string | Page; } | null; url?: string | null; @@ -414,7 +406,3 @@ export interface SettingsSite { updatedAt?: string | null; createdAt?: string | null; } - -declare module "payload" { - export interface GeneratedTypes extends Config {} -} diff --git a/apps/roboshield/payload.config.ts b/apps/roboshield/payload.config.ts index e1a46bf46..c6aa8c5c0 100644 --- a/apps/roboshield/payload.config.ts +++ b/apps/roboshield/payload.config.ts @@ -122,4 +122,7 @@ export default buildConfig({ }), ] as any[], telemetry: process?.env?.NODE_ENV !== "production", + typescript: { + declare: false, + }, }); diff --git a/apps/roboshield/src/lib/payload/index.ts b/apps/roboshield/src/lib/payload/index.ts index 30216832d..94178357f 100644 --- a/apps/roboshield/src/lib/payload/index.ts +++ b/apps/roboshield/src/lib/payload/index.ts @@ -16,7 +16,7 @@ async function findPage(slug: string): Promise> { equals: slug, }, }, - }); + }) as unknown as PaginatedDocs; } async function getCollection( @@ -27,7 +27,7 @@ async function getCollection( limit: 0, ...options, collection, - }); + }) as unknown as Promise>; } async function findGlobal( @@ -37,7 +37,7 @@ async function findGlobal( return payload.findGlobal({ ...options, slug, - }); + }) as unknown as Promise; } async function createCollection( @@ -49,7 +49,7 @@ async function createCollection( collection, data, ...options, - }); + }) as unknown as Promise; } async function deleteCollection( @@ -59,7 +59,7 @@ async function deleteCollection( return payload.delete({ ...options, collection, - }); + }) as unknown as Promise; } async function updateCollection( @@ -74,7 +74,7 @@ async function updateCollection( id, data, }; - return payload.update(args); + return payload.update(args) as unknown as Promise; } const api = { createCollection, From 70a2dc627cfd090d2f07497772cfe1c4cd4fb7ee Mon Sep 17 00:00:00 2001 From: Michael Hudson Nkotagu Date: Tue, 16 Jul 2024 16:15:17 +0300 Subject: [PATCH 4/7] chore: fix formatting issues on payload types --- apps/roboshield/payload-types.ts | 68 ++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/apps/roboshield/payload-types.ts b/apps/roboshield/payload-types.ts index 18b4b04eb..9ca401cb1 100644 --- a/apps/roboshield/payload-types.ts +++ b/apps/roboshield/payload-types.ts @@ -11,11 +11,11 @@ export interface Config { media: Media; pages: Page; users: User; - 'payload-preferences': PayloadPreference; - 'payload-migrations': PayloadMigration; + "payload-preferences": PayloadPreference; + "payload-migrations": PayloadMigration; }; globals: { - 'settings-site': SettingsSite; + "settings-site": SettingsSite; }; } /** @@ -53,7 +53,7 @@ export interface Page { subtitle: string; id?: string | null; blockName?: string | null; - blockType: 'page-header'; + blockType: "page-header"; } | SiteHero | { @@ -65,30 +65,30 @@ export interface Page { }[]; id?: string | null; blockName?: string | null; - blockType: 'richtext'; + blockType: "richtext"; } | { image: string | Media; id?: string | null; blockName?: string | null; - blockType: 'mediaBlock'; + blockType: "mediaBlock"; } | { externalEmbedFields?: { - embedType?: ('url' | 'code') | null; + embedType?: ("url" | "code") | null; url?: string | null; caption?: string | null; code?: string | null; }; id?: string | null; blockName?: string | null; - blockType: 'externalEmbed'; + blockType: "externalEmbed"; } )[] | null; id?: string | null; blockName?: string | null; - blockType: 'content'; + blockType: "content"; } | { title: string; @@ -105,7 +105,7 @@ export interface Page { | null; id?: string | null; blockName?: string | null; - blockType: 'statistics'; + blockType: "statistics"; } | { steps?: @@ -124,7 +124,7 @@ export interface Page { fetch: string; id?: string | null; blockName?: string | null; - blockType: 'existing-robots-txt'; + blockType: "existing-robots-txt"; } | { title: string; @@ -147,7 +147,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: 'delays'; + blockType: "delays"; } | { title: string; @@ -170,7 +170,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: 'paths'; + blockType: "paths"; } | { title: string; @@ -189,7 +189,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: 'block-bots'; + blockType: "block-bots"; } | { title: string; @@ -201,7 +201,7 @@ export interface Page { placeholder: string; id?: string | null; blockName?: string | null; - blockType: 'site-maps'; + blockType: "site-maps"; } | { title: string; @@ -213,7 +213,7 @@ export interface Page { placeholder: string; id?: string | null; blockName?: string | null; - blockType: 'finish'; + blockType: "finish"; } )[] | null; @@ -227,7 +227,7 @@ export interface Page { }; id?: string | null; blockName?: string | null; - blockType: 'robots-txt-generator'; + blockType: "robots-txt-generator"; } )[] | null; @@ -247,7 +247,7 @@ export interface Page { | null; updatedAt: string; createdAt: string; - _status?: ('draft' | 'published') | null; + _status?: ("draft" | "published") | null; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -256,7 +256,7 @@ export interface Page { export interface SiteHero { heroHeaders?: | { - headingType?: ('largeHeading' | 'subHeading' | 'rotatingText') | null; + headingType?: ("largeHeading" | "subHeading" | "rotatingText") | null; title?: string | null; id?: string | null; }[] @@ -267,7 +267,7 @@ export interface SiteHero { heroCallToAction?: string | null; id?: string | null; blockName?: string | null; - blockType: 'page-hero'; + blockType: "page-hero"; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -277,7 +277,7 @@ export interface User { id: string; firstName: string; lastName: string; - roles: ('admin' | 'editor')[]; + roles: ("admin" | "editor")[]; updatedAt: string; createdAt: string; email: string; @@ -298,7 +298,7 @@ export interface User { export interface PayloadPreference { id: string; user: { - relationTo: 'users'; + relationTo: "users"; value: string | User; }; key?: string | null; @@ -341,9 +341,9 @@ export interface SettingsSite { menus?: | { label: string; - linkType?: ('custom' | 'internal') | null; + linkType?: ("custom" | "internal") | null; doc?: { - relationTo: 'pages'; + relationTo: "pages"; value: string | Page; } | null; url?: string | null; @@ -351,15 +351,17 @@ export interface SettingsSite { id?: string | null; }[] | null; - connect?: ('Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack') | null; + connect?: + | ("Facebook" | "Twitter" | "Instagram" | "Linkedin" | "Github" | "Slack") + | null; }; secondaryNavigation?: { menus?: | { label: string; - linkType?: ('custom' | 'internal') | null; + linkType?: ("custom" | "internal") | null; doc?: { - relationTo: 'pages'; + relationTo: "pages"; value: string | Page; } | null; url?: string | null; @@ -372,7 +374,13 @@ export interface SettingsSite { title: string; links?: | { - platform: 'Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack'; + platform: + | "Facebook" + | "Twitter" + | "Instagram" + | "Linkedin" + | "Github" + | "Slack"; url: string; id?: string | null; }[] @@ -392,9 +400,9 @@ export interface SettingsSite { name: string; logo: string | Media; label: string; - linkType?: ('custom' | 'internal') | null; + linkType?: ("custom" | "internal") | null; doc?: { - relationTo: 'pages'; + relationTo: "pages"; value: string | Page; } | null; url?: string | null; From b7dc14221bd810496af5a15a2dee316a3644bd32 Mon Sep 17 00:00:00 2001 From: Michael Hudson Nkotagu Date: Tue, 16 Jul 2024 18:36:16 +0300 Subject: [PATCH 5/7] fix: Update generate:types and build-payload to use PAYLOAD_PUBLIC_APP_URL environment variables --- apps/roboshield/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/roboshield/package.json b/apps/roboshield/package.json index e180b942d..4196edb5f 100644 --- a/apps/roboshield/package.json +++ b/apps/roboshield/package.json @@ -5,14 +5,14 @@ "scripts": { "build-server": "tsc --project tsconfig.server.json", "build-next": "NEXT_BUILD=true pnpm build-server && NEXT_BUILD=true PAYLOAD_CONFIG_PATH=${PAYLOAD_CONFIG_PATH:-dist/payload.config.js} node dist/server.js", - "build-payload": "payload build", + "build-payload": "PAYLOAD_PUBLIC_APP_URL=${PAYLOAD_PUBLIC_APP_URL} payload build", "start": "PAYLOAD_CONFIG_PATH=${PAYLOAD_CONFIG_PATH:-dist/payload.config.js} NODE_ENV=${NODE_ENV:-production} node dist/server.js", "dev": "NODE_OPTIONS='--inspect' ts-node --project tsconfig.server.json server.ts", "clean": "rm -rf .next .turbo node_modules", "jest": "jest --passWithNoTests", "lint-check": "TIMING=1 next lint './'", "lint": "TIMING=1 next lint --fix './'", - "generate:types": "payload generate:types" + "generate:types": "PAYLOAD_PUBLIC_APP_URL=${PAYLOAD_PUBLIC_APP_URL} payload generate:types" }, "dependencies": { "@commons-ui/core": "workspace:*", From 52a587e4a23f91ee51fdcd4b8123497989e852eb Mon Sep 17 00:00:00 2001 From: Michael Hudson Nkotagu Date: Wed, 17 Jul 2024 09:43:34 +0300 Subject: [PATCH 6/7] chore: Use loadEnvConfig to load .env file(s) in payload.config.ts --- apps/roboshield/package.json | 6 +++--- apps/roboshield/payload.config.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/roboshield/package.json b/apps/roboshield/package.json index 4196edb5f..043bccbb6 100644 --- a/apps/roboshield/package.json +++ b/apps/roboshield/package.json @@ -1,18 +1,18 @@ { "name": "roboshield", - "version": "0.1.4", + "version": "0.1.5", "private": true, "scripts": { "build-server": "tsc --project tsconfig.server.json", "build-next": "NEXT_BUILD=true pnpm build-server && NEXT_BUILD=true PAYLOAD_CONFIG_PATH=${PAYLOAD_CONFIG_PATH:-dist/payload.config.js} node dist/server.js", - "build-payload": "PAYLOAD_PUBLIC_APP_URL=${PAYLOAD_PUBLIC_APP_URL} payload build", + "build-payload": "payload build", "start": "PAYLOAD_CONFIG_PATH=${PAYLOAD_CONFIG_PATH:-dist/payload.config.js} NODE_ENV=${NODE_ENV:-production} node dist/server.js", "dev": "NODE_OPTIONS='--inspect' ts-node --project tsconfig.server.json server.ts", "clean": "rm -rf .next .turbo node_modules", "jest": "jest --passWithNoTests", "lint-check": "TIMING=1 next lint './'", "lint": "TIMING=1 next lint --fix './'", - "generate:types": "PAYLOAD_PUBLIC_APP_URL=${PAYLOAD_PUBLIC_APP_URL} payload generate:types" + "generate:types": "payload generate:types" }, "dependencies": { "@commons-ui/core": "workspace:*", diff --git a/apps/roboshield/payload.config.ts b/apps/roboshield/payload.config.ts index c6aa8c5c0..8906a1cc4 100644 --- a/apps/roboshield/payload.config.ts +++ b/apps/roboshield/payload.config.ts @@ -5,7 +5,6 @@ import { webpackBundler } from "@payloadcms/bundler-webpack"; import { CollectionConfig, GlobalConfig } from "payload/types"; import { cloudStorage } from "@payloadcms/plugin-cloud-storage"; import Site from "./src/payload/globals/Site"; -import dotenv from "dotenv"; import Media from "./src/payload/collections/Media"; import Pages from "./src/payload/collections/Pages"; import seo from "@payloadcms/plugin-seo"; @@ -13,9 +12,10 @@ import nestedDocs from "@payloadcms/plugin-nested-docs"; import { s3Adapter } from "@payloadcms/plugin-cloud-storage/s3"; import Users from "./src/payload/collections/Users"; import { defaultLocale, locales } from "./src/payload/utils/locales"; +import { loadEnvConfig } from "@next/env"; -dotenv.config(); -dotenv.config({ path: "./.env.local" }); +const projectDir = process.cwd(); +loadEnvConfig(projectDir); const appURL = process?.env?.PAYLOAD_PUBLIC_APP_URL; From ecd189c6d0a0f0c8e2b907eacf92dab4f9cc4f2d Mon Sep 17 00:00:00 2001 From: Michael Hudson Nkotagu Date: Wed, 17 Jul 2024 12:51:30 +0300 Subject: [PATCH 7/7] chore: Revert to default configuration of payload generated types --- apps/roboshield/payload-types.ts | 4 ++++ apps/roboshield/payload.config.ts | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/roboshield/payload-types.ts b/apps/roboshield/payload-types.ts index 9ca401cb1..6928f0159 100644 --- a/apps/roboshield/payload-types.ts +++ b/apps/roboshield/payload-types.ts @@ -414,3 +414,7 @@ export interface SettingsSite { updatedAt?: string | null; createdAt?: string | null; } + +declare module "payload" { + export interface GeneratedTypes extends Config {} +} diff --git a/apps/roboshield/payload.config.ts b/apps/roboshield/payload.config.ts index 8906a1cc4..ed46ab712 100644 --- a/apps/roboshield/payload.config.ts +++ b/apps/roboshield/payload.config.ts @@ -122,7 +122,4 @@ export default buildConfig({ }), ] as any[], telemetry: process?.env?.NODE_ENV !== "production", - typescript: { - declare: false, - }, });