Skip to content

A self-hosted media server and file management system

feat: minimal manifest implementation

aminnausin7cbadac3ce10
diff --git a/app/Console/Commands/GenerateManifest.php b/app/Console/Commands/GenerateManifest.php
new file mode 100644
index 00000000..cf2926b7
--- /dev/null
+++ b/app/Console/Commands/GenerateManifest.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\File;
+
+class GenerateManifest extends Command {
+ protected $signature = 'app:manifest';
+
+ protected $description = 'Generate the current Git version and commit hash to a manifest';
+
+ public function handle() {
+ $version = trim(shell_exec('git describe --tags --abbrev=0')) ?: 'unversioned';
+ $commit = trim(shell_exec('git rev-parse --short HEAD')) ?: 'unknown';
+
+ $data = json_encode([
+ 'version' => $version,
+ 'commit' => $commit,
+ ], JSON_PRETTY_PRINT);
+
+ File::put(storage_path('app/manifest.json'), $data);
+
+ $this->info("App manifest generated: $version ($commit)");
+ }
+}
diff --git a/app/Support/AppManifest.php b/app/Support/AppManifest.php
new file mode 100644
index 00000000..26153766
--- /dev/null
+++ b/app/Support/AppManifest.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Support;
+
+use Illuminate\Support\Facades\File;
+
+class AppManifest {
+ public static function info(): array {
+ $path = storage_path('app/manifest.json');
+
+ if (! File::exists($path)) {
+ return ['version' => 'unknown', 'commit' => null];
+ }
+
+ $data = json_decode(File::get($path), true);
+
+ return [
+ 'version' => $data['version'] ?? 'unknown',
+ 'commit' => $data['commit'] ?? null,
+ ];
+ }
+
+ public static function string(): string {
+ $info = self::info();
+
+ return "{$info['version']} (#{$info['commit']})";
+ }
+}
diff --git a/resources/js/service/queries.ts b/resources/js/service/queries.ts
index a40d5fff..23380ddf 100644
--- a/resources/js/service/queries.ts
+++ b/resources/js/service/queries.ts
@@ -1,8 +1,8 @@
import type { CategoryResource, FolderResource, TaskResource, UserResource } from '@/types/resources';
-import type { PulseResponse, TaskStatsResponse } from '@/types/types.ts';
+import type { AppManifest, PulseResponse, TaskStatsResponse } from '@/types/types.ts';
import type { Ref } from 'vue';
-import { getSiteAnalytics, getPulse, getUsers, getTasks, getTaskStats, getActiveSessions } from '@/service/siteAPI.ts';
+import { getSiteAnalytics, getPulse, getUsers, getTasks, getTaskStats, getActiveSessions, getManifest } from '@/service/siteAPI.ts';
import { useAuthStore } from '@/stores/AuthStore';
import { storeToRefs } from 'pinia';
import { useQuery } from '@tanstack/vue-query';
@@ -115,6 +115,16 @@ export const useGetActiveSessions = () => {
});
};
+export const useGetManifest = () => {
+ return useQuery<{ data: AppManifest }>({
+ queryKey: ['manifest'],
+ queryFn: async () => {
+ const { data: response } = await getManifest();
+ return response;
+ },
+ });
+};
+
// export const useGetChatRoomMessagesQuery = (chat_id: number | null) => {
// return useInfiniteQuery({
// queryKey: ['chatroom-messages', chat_id],
diff --git a/resources/js/service/siteAPI.ts b/resources/js/service/siteAPI.ts
index e785e011..a6c8b96a 100644
--- a/resources/js/service/siteAPI.ts
+++ b/resources/js/service/siteAPI.ts
@@ -77,3 +77,7 @@ export function deleteSubTask(taskId: number) {
export function deleteUser(userId: number) {
return API.delete(`/users/${userId}`);
}
+
+export function getManifest() {
+ return API.get('/manifest');
+}
diff --git a/resources/js/stores/AppStore.ts b/resources/js/stores/AppStore.ts
index eaa1ce68..fe7533ed 100644
--- a/resources/js/stores/AppStore.ts
+++ b/resources/js/stores/AppStore.ts
@@ -1,5 +1,6 @@
-import { type ContextMenu as ContextMenuType, type ContextMenuItem, type Broadcaster } from '@/types/types';
-import { nextTick, ref, useTemplateRef } from 'vue';
+import { type ContextMenu as ContextMenuType, type ContextMenuItem, type Broadcaster, type AppManifest } from '@/types/types';
+import { nextTick, ref, useTemplateRef, watch } from 'vue';
+import { useGetManifest } from '@/service/queries';
import { defineStore } from 'pinia';
import { EchoConfig } from '@/echo.ts';
@@ -25,6 +26,9 @@ export const useAppStore = defineStore('App', () => {
const contextMenu = useTemplateRef<InstanceType<typeof ContextMenu> | null>('contextMenu');
+ const { data: rawAppManifest } = useGetManifest();
+ const appManifest = ref<AppManifest>({ version: 'Unversioned', commit: null });
+
function toggleDarkMode() {
let rootHTML = document.querySelector('html');
@@ -114,6 +118,10 @@ export const useAppStore = defineStore('App', () => {
}
};
+ watch(rawAppManifest, (v: AppManifest) => {
+ appManifest.value = v ?? { version: 'Unversioned', commit: 'unknown' };
+ });
+
return {
initDarkMode,
toggleDarkMode,
@@ -137,7 +145,8 @@ export const useAppStore = defineStore('App', () => {
setContextMenu,
createEcho,
disconnectEcho,
- ws,
isAutoPlay,
+ ws,
+ appManifest,
};
});
diff --git a/resources/js/types/types.ts b/resources/js/types/types.ts
index 2c0c8d2b..1a4aab74 100644
--- a/resources/js/types/types.ts
+++ b/resources/js/types/types.ts
@@ -297,3 +297,8 @@ export interface DropdownMenuItem {
action?: () => void;
shortcut?: string;
}
+
+export interface AppManifest {
+ version: string;
+ commit: string | null;
+}
diff --git a/resources/js/views/DashboardView.vue b/resources/js/views/DashboardView.vue
index ca417681..a1f67469 100644
--- a/resources/js/views/DashboardView.vue
+++ b/resources/js/views/DashboardView.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import type { TaskStatsResponse } from '@/types/types';
+import type { AppManifest, TaskStatsResponse } from '@/types/types';
import { computed, onMounted, ref, watch, type Component, type Ref } from 'vue';
import { useDashboardStore } from '@/stores/DashboardStore';
@@ -17,6 +17,8 @@ import SidebarCard from '@/components/cards/SidebarCard.vue';
import LayoutBase from '@/layouts/LayoutBase.vue';
import ProiconsLibrary from '~icons/proicons/library';
+import ProiconsServer from '~icons/proicons/server';
+import ProiconsGithub from '~icons/proicons/github';
import ProiconsGraph from '~icons/proicons/graph';
import CircumServer from '~icons/circum/server';
import LucideUsers from '~icons/lucide/users';
@@ -27,7 +29,7 @@ const { stateTaskStats, stateTotalLibrariesSize, stateLibraryId, stateActiveSess
stateLibraryId: Ref<number>;
stateActiveSessions: Ref<number>;
};
-const { pageTitle, selectedSideBar } = storeToRefs(useAppStore());
+const { pageTitle, selectedSideBar, appManifest } = storeToRefs(useAppStore()) as unknown as { pageTitle: Ref<any>; selectedSideBar: Ref<any>; appManifest: Ref<AppManifest> };
const { cycleSideBar } = useAppStore();
const { userData } = storeToRefs(useAuthStore());
@@ -123,7 +125,7 @@ watch(
<h2 id="sidebar-title" class="text-2xl h-8 w-full capitalize dark:text-white">{{ selectedSideBar }}</h2>
<hr class="" />
</div>
- <section class="flex flex-col gap-2">
+ <section class="flex flex-col gap-2 flex-1">
<SidebarCard
v-for="(tab, index) in dashboardTabs.filter((tab) => !tab.disabled)"
:key="index"
@@ -143,7 +145,7 @@ watch(
:aria-disabled="tab.disabled"
>
<template #header>
- <h3 class="w-full flex-1" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>
+ <h3 class="w-full flex-1 text-gray-900 dark:text-white" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>
<component v-if="tab.icon" :is="tab.icon" class="ml-auto w-6 h-6" />
</template>
<template #body>
@@ -156,6 +158,29 @@ watch(
</h4>
</template>
</SidebarCard>
+
+ <SidebarCard
+ :to="`${appManifest?.commit ? `https://github.com/aminnausin/mediaServer/commit/${appManifest?.commit}` : ''}`"
+ :class="`
+ items-center justify-between text-sm
+ capitalize overflow-hidden bg-white hover:bg-primary-800
+ ring-inset ring-purple-600 hover:ring-purple-600/50 hover:ring-[0.125rem]
+ aria-disabled:cursor-not-allowed aria-disabled:hover:ring-neutral-200 aria-disabled:hover:dark:ring-neutral-700 aria-disabled:opacity-60
+ `"
+ @click=""
+ :aria-disabled="false"
+ >
+ <template #header>
+ <h3 class="text-gray-900 dark:text-white" :title="'Source Code'">#{{ appManifest.commit }}</h3>
+ <ProiconsGithub class="ml-auto w-6 h-6" />
+ </template>
+ <template #body>
+ <h4 title="Description" class="text-neutral-500 w-full text-wrap truncate sm:text-nowrap flex-1">MediaServer</h4>
+ <h4 v-if="appManifest.commit" title="Information" class="truncate text-nowrap sm:text-right text-neutral-500 w-fit">
+ {{ appManifest.version ?? 'V0.1.15b' }}
+ </h4>
+ </template>
+ </SidebarCard>
</section>
</div>
</template>
diff --git a/routes/api.php b/routes/api.php
index 2707fe7f..3c60395e 100755
--- a/routes/api.php
+++ b/routes/api.php
@@ -16,6 +16,7 @@ use App\Http\Controllers\Api\V1\TaskController;
use App\Http\Controllers\Api\V1\UserController;
use App\Http\Controllers\Api\V1\VideoController;
use App\Http\Controllers\DirectoryController;
+use App\Support\AppManifest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Robertogallea\PulseApi\Http\Controllers\DashboardController;
@@ -66,6 +67,10 @@ Route::prefix('pulse')->group(function () {
// public
+Route::get('/manifest', function () {
+ return response()->json(AppManifest::info());
+});
+
Route::post('/login', [AuthController::class, 'login']);
Route::post('/register', [AuthController::class, 'register']);
Route::patch('/videos/watch/{video}', [VideoController::class, 'watch']);
diff --git a/storage/app/manifest.json b/storage/app/manifest.json
new file mode 100644
index 00000000..d40e8b17
--- /dev/null
+++ b/storage/app/manifest.json
@@ -0,0 +1,4 @@
+{
+ "version": "beta-088f1c9",
+ "commit": "f5a21892"
+}
\ No newline at end of file