Align dashboard and installer flows with spec

This commit is contained in:
2026-05-08 19:02:50 +09:00
parent a10ca67210
commit 5ff4e20b5e
6 changed files with 117 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ import { fetchReleaseVersions } from '../../shared/mojang'
import {
createNewPack,
deletePacks,
listDashboardPacks,
loadAccounts,
loadPackDefinition,
loadRootManifest,
@@ -59,10 +60,10 @@ opRouter.post('/op/logout', requireAuth, (req, res) => {
opRouter.get('/op/dashboard', requireAuth, async (_req, res, next) => {
try {
const manifest = await loadRootManifest()
const packs = await listDashboardPacks()
res.render('op/dashboard', {
userId: _req.session.userId,
packs: manifest.packs
packs
})
} catch (error) {
next(error)

View File

@@ -2,7 +2,7 @@ import fs from 'node:fs'
import fsp from 'node:fs/promises'
import path from 'node:path'
import { accountPath, fileDir, manifestDir, manifestRootPath } from './paths'
import { AccountEntry, PackDefinition, PackListEntry, RootManifest } from './types'
import { AccountEntry, DashboardPackEntry, PackDefinition, PackListEntry, RootManifest } from './types'
const defaultRootManifest: RootManifest = {
packs: [
@@ -93,6 +93,22 @@ export async function listManifestFiles(): Promise<string[]> {
.sort((left, right) => left.localeCompare(right))
}
export async function listDashboardPacks(): Promise<DashboardPackEntry[]> {
const [manifestFiles, rootManifest] = await Promise.all([
listManifestFiles(),
loadRootManifest()
])
return manifestFiles.map((file) => {
const registeredPack = rootManifest.packs.find((entry) => entry.file === file)
return {
file,
name: registeredPack?.name ?? file,
registered: registeredPack != null
}
})
}
export async function loadPackDefinition(packKey: string): Promise<PackDefinition | null> {
await ensureProjectFiles()
const safeKey = sanitizePackKey(packKey)

View File

@@ -3,6 +3,10 @@ export interface PackListEntry {
file: string
}
export interface DashboardPackEntry extends PackListEntry {
registered: boolean
}
export interface RootManifest {
packs: PackListEntry[]
}