Switch mods to per-folder auto-discovery and resourcepack to single zip
- PackDefinition: replace mods[]/resourcepacks[] with modsFolder (string) + resourcepackPath (string); drop PackAsset - Editor: replace dynamic add/remove lists with two single inputs; remove the now-dead JS for adding/removing rows - Server: expose GET /file/mods/<folder>/index.json that returns the list of .jar names; folder name restricted to [a-zA-Z0-9_-]+ - Installer: fetch the listing JSON and download each jar from /file/mods/<folder>/<file>.jar; download the single resourcepack from /file/resourcepacks/<file>.zip directly into resourcepacks/ Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import express from 'express'
|
||||
import session from 'express-session'
|
||||
import path from 'node:path'
|
||||
import fsp from 'node:fs/promises'
|
||||
import { manifestRootPath, manifestDirPath, fileDirPath, viewsDirPath, publicDirPath } from '../shared/paths'
|
||||
import { indexRouter } from './routes/index'
|
||||
import { opRouter } from './routes/op'
|
||||
@@ -69,6 +70,30 @@ app.use((req, res, next) => {
|
||||
next()
|
||||
})
|
||||
|
||||
// 모드 폴더 안의 .jar 파일 목록을 JSON으로 반환. 설치기가 자동 다운로드용으로 사용.
|
||||
app.get('/file/mods/:folder/index.json', async (req, res) => {
|
||||
const folder = req.params.folder
|
||||
if (!/^[a-zA-Z0-9_\-]+$/.test(folder)) {
|
||||
res.status(404).json({ files: [] })
|
||||
return
|
||||
}
|
||||
const dir = path.join(fileDirPath, 'mods', folder)
|
||||
try {
|
||||
const entries = await fsp.readdir(dir)
|
||||
const files = entries
|
||||
.filter((name) => /\.jar$/i.test(name))
|
||||
.filter((name) => !name.includes('/') && !name.includes('\\'))
|
||||
.sort()
|
||||
res.json({ files })
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
||||
res.status(404).json({ files: [] })
|
||||
return
|
||||
}
|
||||
throw error
|
||||
}
|
||||
})
|
||||
|
||||
app.use('/file', express.static(fileDirPath, { fallthrough: true, index: false }))
|
||||
|
||||
app.use('/', indexRouter)
|
||||
|
||||
Reference in New Issue
Block a user