chore: include package.json version and commit hash in panel

This commit is contained in:
fero
2024-03-09 12:02:07 -07:00
parent 7e335484df
commit 80ddef9079
9 changed files with 46 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
{ {
"name": "pterodactyl-panel", "name": "pyrodactyl",
"version": "0.40.0-alpha",
"engines": { "engines": {
"node": ">=20.0" "node": ">=20.0"
}, },

View File

@@ -5,12 +5,13 @@ import ConfigureTwoFactorForm from '@/components/dashboard/forms/ConfigureTwoFac
import PageContentBlock from '@/components/elements/PageContentBlock'; import PageContentBlock from '@/components/elements/PageContentBlock';
import MessageBox from '@/components/MessageBox'; import MessageBox from '@/components/MessageBox';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import Code from '../elements/Code';
export default () => { export default () => {
const { state } = useLocation<undefined | { twoFactorRedirect?: boolean }>(); const { state } = useLocation();
return ( return (
<PageContentBlock title={'Account Overview'}> <PageContentBlock title={'Your Settings'}>
<h1 className='text-[52px] font-extrabold leading-[98%] tracking-[-0.14rem] mb-8'>Your Settings</h1> <h1 className='text-[52px] font-extrabold leading-[98%] tracking-[-0.14rem] mb-8'>Your Settings</h1>
{state?.twoFactorRedirect && ( {state?.twoFactorRedirect && (
<MessageBox title={'2-Factor Required'} type={'error'}> <MessageBox title={'2-Factor Required'} type={'error'}>
@@ -18,7 +19,7 @@ export default () => {
</MessageBox> </MessageBox>
)} )}
<div className='flex flex-col w-full h-full'> <div className='flex flex-col w-full h-full gap-8'>
<ContentBox title={'Update Password'} showFlashes={'account:password'}> <ContentBox title={'Update Password'} showFlashes={'account:password'}>
<UpdatePasswordForm /> <UpdatePasswordForm />
</ContentBox> </ContentBox>
@@ -28,6 +29,15 @@ export default () => {
<ContentBox title={'Two-Step Verification'}> <ContentBox title={'Two-Step Verification'}>
<ConfigureTwoFactorForm /> <ConfigureTwoFactorForm />
</ContentBox> </ContentBox>
<ContentBox title={'Panel Version'}>
<p className='text-sm mb-4'>
This is useful to provide Pyro staff if you run into an unexpected issue.
</p>
<div className='flex flex-col gap-4'>
<Code>{import.meta.env.VITE_PYRODACTYL_VERSION}</Code>
<Code>Commit {import.meta.env.VITE_COMMIT_HASH.slice(0, 7)}</Code>
</div>
</ContentBox>
</div> </div>
</PageContentBlock> </PageContentBlock>
); );

View File

@@ -8,8 +8,8 @@ interface CodeProps {
export default ({ dark, className, children }: CodeProps) => ( export default ({ dark, className, children }: CodeProps) => (
<code <code
className={clsx('font-mono text-sm px-2 py-1 inline-block rounded', className, { className={clsx('font-mono text-sm px-2 py-1 inline-block rounded w-fit', className, {
'bg-zinc-700': !dark, 'bg-zinc-900': !dark,
'bg-zinc-900 text-zinc-100': dark, 'bg-zinc-900 text-zinc-100': dark,
})} })}
> >

View File

@@ -11,11 +11,9 @@ type Props = Readonly<
>; >;
const ContentBox = ({ title, borderColor, showFlashes, showLoadingOverlay, children, ...props }: Props) => ( const ContentBox = ({ title, borderColor, showFlashes, showLoadingOverlay, children, ...props }: Props) => (
<div {...props}> <div className='p-8 bg-[#ffffff09] border-[1px] border-[#ffffff11] shadow-sm rounded-xl' {...props}>
{title && <h2 className={`text-zinc-300 mb-4 px-4 text-2xl`}>{title}</h2>} {title && <h2 className={`font-extrabold mb-4 text-2xl`}>{title}</h2>}
{showFlashes && ( {showFlashes && <FlashMessageRender byKey={typeof showFlashes === 'string' ? showFlashes : undefined} />}
<FlashMessageRender byKey={typeof showFlashes === 'string' ? showFlashes : undefined} />
)}
<div> <div>
<SpinnerOverlay visible={showLoadingOverlay || false} /> <SpinnerOverlay visible={showLoadingOverlay || false} />
{children} {children}

View File

@@ -1,4 +1,4 @@
import { Route, Routes, useNavigate } from 'react-router-dom'; import { Route, Routes } from 'react-router-dom';
import LoginContainer from '@/components/auth/LoginContainer'; import LoginContainer from '@/components/auth/LoginContainer';
import ForgotPasswordContainer from '@/components/auth/ForgotPasswordContainer'; import ForgotPasswordContainer from '@/components/auth/ForgotPasswordContainer';
@@ -7,8 +7,6 @@ import LoginCheckpointContainer from '@/components/auth/LoginCheckpointContainer
import { NotFound } from '@/components/elements/ScreenBlock'; import { NotFound } from '@/components/elements/ScreenBlock';
export default () => { export default () => {
const navigate = useNavigate();
return ( return (
<div <div
style={{ style={{
@@ -21,7 +19,7 @@ export default () => {
<Route path='login/checkpoint/*' element={<LoginCheckpointContainer />} /> <Route path='login/checkpoint/*' element={<LoginCheckpointContainer />} />
<Route path='password' element={<ForgotPasswordContainer />} /> <Route path='password' element={<ForgotPasswordContainer />} />
<Route path='password/reset/:token' element={<ResetPasswordContainer />} /> <Route path='password/reset/:token' element={<ResetPasswordContainer />} />
<Route path='*' element={<NotFound onBack={() => navigate('/auth/login')} />} /> <Route path='*' element={<NotFound />} />
</Routes> </Routes>
</div> </div>
); );

View File

@@ -85,11 +85,11 @@ export default () => {
<div className='pyro-subnav-routes-wrapper'> <div className='pyro-subnav-routes-wrapper'>
<NavLink to={'/'} end className='flex flex-row items-center'> <NavLink to={'/'} end className='flex flex-row items-center'>
<HugeIconsHome fill='currentColor' /> <HugeIconsHome fill='currentColor' />
<p>Your Servers</p> <p>Servers</p>
</NavLink> </NavLink>
<NavLink to={'/account'} end className='flex flex-row items-center'> <NavLink to={'/account'} end className='flex flex-row items-center'>
<HugeIconsDashboardSettings fill='currentColor' /> <HugeIconsDashboardSettings fill='currentColor' />
<p>Your Settings</p> <p>Settings</p>
</NavLink> </NavLink>
</div> </div>
</MainSidebar> </MainSidebar>

11
resources/scripts/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_PYRODACTYL_VERSION: string;
readonly VITE_COMMIT_HASH: string;
readonly VITE_BRANCH_NAME: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

View File

@@ -45,6 +45,6 @@
"stripInternal": true, "stripInternal": true,
"useDefineForClassFields": true "useDefineForClassFields": true
}, },
"include": ["./resources/scripts/**/*", "vite.config.ts"], "include": ["./resources/scripts/**/*", "vite.config.ts", "./package.json"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }

View File

@@ -5,6 +5,11 @@ import { fileURLToPath } from 'node:url';
import manifestSRI from 'vite-plugin-manifest-sri'; import manifestSRI from 'vite-plugin-manifest-sri';
import { splitVendorChunkPlugin } from 'vite'; import { splitVendorChunkPlugin } from 'vite';
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import packageJson from './package.json';
import * as child from 'child_process';
const branchName = child.execSync('git rev-parse --abbrev-ref HEAD').toString().trimEnd();
const commitHash = child.execSync('git rev-parse HEAD').toString().trimEnd();
export default defineConfig({ export default defineConfig({
build: { build: {
@@ -31,6 +36,9 @@ export default defineConfig({
}, },
define: { define: {
'import.meta.env.VITE_PYRODACTYL_VERSION': JSON.stringify(packageJson.version),
'import.meta.env.VITE_COMMIT_HASH': JSON.stringify(commitHash),
'import.meta.env.VITE_BRANCH_NAME': JSON.stringify(branchName),
'process.env': {}, 'process.env': {},
'process.platform': null, 'process.platform': null,
'process.version': null, 'process.version': null,
@@ -62,7 +70,7 @@ export default defineConfig({
'resources', 'resources',
'scripts', 'scripts',
'api', 'api',
'definitions' 'definitions',
), ),
'@feature': resolve( '@feature': resolve(
dirname(fileURLToPath(import.meta.url)), dirname(fileURLToPath(import.meta.url)),
@@ -70,7 +78,7 @@ export default defineConfig({
'scripts', 'scripts',
'components', 'components',
'server', 'server',
'features' 'features',
), ),
}, },
}, },