1
0
Fork 0

feat: display app version using environment variable and add VersionOverlay component, add migration for new database tables

This commit is contained in:
Jason Fraley 2025-12-22 16:07:48 -05:00
parent fc9cbf9bf1
commit 2727580c24
7 changed files with 9051 additions and 1 deletions

View file

@ -1,8 +1,13 @@
import { withPayload } from "@payloadcms/next/withPayload"; import { withPayload } from "@payloadcms/next/withPayload";
import packageJson from "./package.json" with { type: "json" };
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
// Your Next.js config here // Your Next.js config here
env: {
version: packageJson.version,
},
webpack: (webpackConfig) => { webpack: (webpackConfig) => {
webpackConfig.resolve.extensionAlias = { webpackConfig.resolve.extensionAlias = {
".cjs": [".cts", ".cjs"], ".cjs": [".cts", ".cjs"],

View file

@ -23,6 +23,7 @@ import { BoldFeatureClient as BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864
import { ItalicFeatureClient as ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client' import { ItalicFeatureClient as ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
import { default as default_2d468cc5cf0b647ffca3201592c20825 } from '@/components/static/WarningMessage' import { default as default_2d468cc5cf0b647ffca3201592c20825 } from '@/components/static/WarningMessage'
import { default as default_0edde40a6ccd30c893b1227360f69360 } from '@/components/static/TickDurationDescription' import { default as default_0edde40a6ccd30c893b1227360f69360 } from '@/components/static/TickDurationDescription'
import { default as default_2f6c866ab4d4d51b3789f090b84b85c7 } from '@/components/static/VersionOverlay'
import { default as default_508743824696caae2894ebf34c2e68bb } from '@/components/graphics/AppIcon' import { default as default_508743824696caae2894ebf34c2e68bb } from '@/components/graphics/AppIcon'
import { default as default_e752fee78378294ff03f91dba0a75a04 } from '@/components/graphics/AppLogo' import { default as default_e752fee78378294ff03f91dba0a75a04 } from '@/components/graphics/AppLogo'
import { default as default_05548cb43495e62d80b80ec4d9f0f7e9 } from '@/components/static/BeforeDashboardText' import { default as default_05548cb43495e62d80b80ec4d9f0f7e9 } from '@/components/static/BeforeDashboardText'
@ -53,6 +54,7 @@ export const importMap = {
"@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, "@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
"@/components/static/WarningMessage#default": default_2d468cc5cf0b647ffca3201592c20825, "@/components/static/WarningMessage#default": default_2d468cc5cf0b647ffca3201592c20825,
"@/components/static/TickDurationDescription#default": default_0edde40a6ccd30c893b1227360f69360, "@/components/static/TickDurationDescription#default": default_0edde40a6ccd30c893b1227360f69360,
"@/components/static/VersionOverlay#default": default_2f6c866ab4d4d51b3789f090b84b85c7,
"@/components/graphics/AppIcon#default": default_508743824696caae2894ebf34c2e68bb, "@/components/graphics/AppIcon#default": default_508743824696caae2894ebf34c2e68bb,
"@/components/graphics/AppLogo#default": default_e752fee78378294ff03f91dba0a75a04, "@/components/graphics/AppLogo#default": default_e752fee78378294ff03f91dba0a75a04,
"@/components/static/BeforeDashboardText#default": default_05548cb43495e62d80b80ec4d9f0f7e9 "@/components/static/BeforeDashboardText#default": default_05548cb43495e62d80b80ec4d9f0f7e9

View file

@ -0,0 +1,11 @@
const VersionOverlay = () => {
const appVersion = process.env.version;
return (
<div className="fixed top-0 z-9999 text-white w-full flex flex-items-center justify-center pointer-events-none">
<span className="text-center text-sm bg-rose-950 px-2 rounded-b">version {appVersion ?? "Unknown version"}</span>
</div>
);
};
export default VersionOverlay;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,30 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
CREATE TABLE "game_hard_resources" (
"id" serial PRIMARY KEY NOT NULL,
"name" varchar NOT NULL,
"amount" numeric DEFAULT 0 NOT NULL,
"description" jsonb NOT NULL,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "game_hard_resources_id" integer;
CREATE UNIQUE INDEX "game_hard_resources_name_idx" ON "game_hard_resources" USING btree ("name");
CREATE INDEX "game_hard_resources_updated_at_idx" ON "game_hard_resources" USING btree ("updated_at");
CREATE INDEX "game_hard_resources_created_at_idx" ON "game_hard_resources" USING btree ("created_at");
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_game_hard_resources_fk" FOREIGN KEY ("game_hard_resources_id") REFERENCES "public"."game_hard_resources"("id") ON DELETE cascade ON UPDATE no action;
CREATE INDEX "payload_locked_documents_rels_game_hard_resources_id_idx" ON "payload_locked_documents_rels" USING btree ("game_hard_resources_id");`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "game_hard_resources" DISABLE ROW LEVEL SECURITY;
DROP TABLE "game_hard_resources" CASCADE;
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_game_hard_resources_fk";
DROP INDEX "payload_locked_documents_rels_game_hard_resources_id_idx";
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "game_hard_resources_id";`)
}

View file

@ -1,6 +1,7 @@
import * as migration_20251206_065831 from './20251206_065831'; import * as migration_20251206_065831 from './20251206_065831';
import * as migration_20251212_183607 from './20251212_183607'; import * as migration_20251212_183607 from './20251212_183607';
import * as migration_20251219_061127 from './20251219_061127'; import * as migration_20251219_061127 from './20251219_061127';
import * as migration_20251222_200320 from './20251222_200320';
export const migrations = [ export const migrations = [
{ {
@ -16,6 +17,11 @@ export const migrations = [
{ {
up: migration_20251219_061127.up, up: migration_20251219_061127.up,
down: migration_20251219_061127.down, down: migration_20251219_061127.down,
name: '20251219_061127' name: '20251219_061127',
},
{
up: migration_20251222_200320.up,
down: migration_20251222_200320.down,
name: '20251222_200320'
}, },
]; ];

View file

@ -51,6 +51,7 @@ export default buildConfig({
}, },
components: { components: {
beforeDashboard: ["@/components/static/BeforeDashboardText"], beforeDashboard: ["@/components/static/BeforeDashboardText"],
header: ["@/components/static/VersionOverlay"],
graphics: { graphics: {
Logo: "@/components/graphics/AppLogo", Logo: "@/components/graphics/AppLogo",
Icon: "@/components/graphics/AppIcon", Icon: "@/components/graphics/AppIcon",