Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2371af4411 | |||
| 1f59f6a98b | |||
| 794ad9b778 |
@@ -128,7 +128,7 @@
|
||||
"resourcepackHint": "/file/resourcepacks/ 아래 .zip 파일 이름. 리소스팩 설치기가 이 zip 위에 음악·사진을 얹어 최종 리소스팩을 만듭니다. 비워두면 처음부터 새로 만듭니다.",
|
||||
"outputPackName": "생성되는 리소스팩 이름",
|
||||
"outputPackNamePlaceholder": "예: 음악퀴즈 테스트팩",
|
||||
"outputPackNameHint": "리소스팩 설치기가 만들어 내는 zip 파일 이름이자, 마인크래프트 리소스팩 목록의 제목이 됩니다. 비워두면 파일이름_musicquiz 형태로 자동 지정됩니다. Windows 파일명 금지 문자(\\ / : * ? \" < > |)는 자동으로 _ 로 바뀝니다.",
|
||||
"outputPackNameHint": "리소스팩 설치기가 만들어 내는 zip 파일 이름이자, 마인크래프트 리소스팩 목록의 제목이 됩니다. 비워두면 파일이름_resourcepack 형태로 자동 지정됩니다. Windows 파일명 금지 문자(\\ / : * ? \" < > |)는 자동으로 _ 로 바뀝니다.",
|
||||
"ramOrderInvalid": "클라이언트 최소 램은 권장 램보다 클 수 없습니다.",
|
||||
"fabricLoaderRequired": "Fabric 로더 버전을 선택해 주세요."
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minecraft-music-quiz-installer",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.3",
|
||||
"description": "마인크래프트 음악퀴즈 간편설치기 + 관리 사이트",
|
||||
"main": "dist/installer/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { promises as fs, createWriteStream, constants as fsConst } from 'node:fs
|
||||
import path from 'node:path'
|
||||
import https from 'node:https'
|
||||
import http from 'node:http'
|
||||
import { getMcCustomDir } from '../shared/paths.js'
|
||||
import { getMcCustomDir, getMcCustomInstallerDir } from '../shared/paths.js'
|
||||
import { loadComponentI18n } from '../shared/i18n.js'
|
||||
|
||||
const { t } = loadComponentI18n('installer-rp')
|
||||
@@ -13,10 +13,30 @@ const extractZip: (source: string, options: { dir: string }) => Promise<void> =
|
||||
|
||||
/**
|
||||
* 리소스팩 간편설치기는 Windows .exe 로 배포되므로 ffmpeg.exe 한 종류만 사용.
|
||||
* 경로: %appdata%/.mc_custom/ffmpeg.exe
|
||||
* 경로: %appdata%/.mc_custom/installer/ffmpeg.exe
|
||||
*/
|
||||
export function getFfmpegExePath(): string {
|
||||
return path.join(getMcCustomDir(), 'ffmpeg.exe')
|
||||
return path.join(getMcCustomInstallerDir(), 'ffmpeg.exe')
|
||||
}
|
||||
|
||||
/**
|
||||
* 0.2.1 이전 버전이 `.mc_custom/ffmpeg.exe` 에 받아둔 파일이 있으면 새 위치로
|
||||
* 옮긴다.
|
||||
*/
|
||||
async function migrateLegacyExe(target: string): Promise<void> {
|
||||
const legacy = path.join(getMcCustomDir(), 'ffmpeg.exe')
|
||||
if (legacy === target) return
|
||||
try {
|
||||
await fs.access(legacy, fsConst.F_OK)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await fs.mkdir(path.dirname(target), { recursive: true })
|
||||
await fs.rename(legacy, target)
|
||||
} catch {
|
||||
try { await fs.unlink(legacy) } catch { /* noop */ }
|
||||
}
|
||||
}
|
||||
|
||||
/** BtbN/FFmpeg-Builds 의 win64-gpl 빌드. zip 내부에 bin/ffmpeg.exe 가 들어 있음. */
|
||||
@@ -33,6 +53,7 @@ export async function ensureFfmpegExe(
|
||||
log?: (line: string) => void
|
||||
): Promise<string> {
|
||||
const target = getFfmpegExePath()
|
||||
await migrateLegacyExe(target)
|
||||
if (await canExecute(target)) {
|
||||
log?.(t('log.ffmpegExists', { path: target }))
|
||||
return target
|
||||
@@ -40,7 +61,7 @@ export async function ensureFfmpegExe(
|
||||
if (installPromise) return installPromise
|
||||
|
||||
installPromise = (async () => {
|
||||
const dir = getMcCustomDir()
|
||||
const dir = getMcCustomInstallerDir()
|
||||
const zipPath = path.join(dir, '.tmp_ffmpeg.zip')
|
||||
const extractDir = path.join(dir, '.tmp_ffmpeg')
|
||||
try {
|
||||
|
||||
@@ -400,9 +400,9 @@ ipcMain.handle('rp:install:start', async (): Promise<{ resourcepackPath: string
|
||||
// 2-5. 리소스팩 zip 빌드 (pack.mcmeta + sounds.json + 음악·이미지, 베이스 위에 얹기)
|
||||
throwIfCancelled()
|
||||
// 사이트에서 지정한 "생성되는 리소스팩 이름" 을 우선 사용. 비어있거나 sanitize
|
||||
// 결과가 빈 문자열이면 `<packKey>_musicquiz` 로 폴백.
|
||||
// 결과가 빈 문자열이면 `<packKey>_resourcepack` 로 폴백.
|
||||
const sanitizedOutputName = sanitizeOutputPackName(pack.outputPackName)
|
||||
const resourcepackBaseName = sanitizedOutputName || `${state.selectedKey}_musicquiz`
|
||||
const resourcepackBaseName = sanitizedOutputName || `${state.selectedKey}_resourcepack`
|
||||
const resourcepackName = `${resourcepackBaseName}.zip`
|
||||
const resourcepackDir = path.join(getMcCustomDir(), 'resourcepacks')
|
||||
const resourcepackPath = path.join(resourcepackDir, resourcepackName)
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface RpFetchedPack {
|
||||
resourcepackPath: string
|
||||
/**
|
||||
* /manifest/<key>.json 의 outputPackName. 관리 사이트에서 설정한 "생성되는
|
||||
* 리소스팩 이름". 비어 있으면 설치기가 `<key>_musicquiz` 형식으로 폴백.
|
||||
* 리소스팩 이름". 비어 있으면 설치기가 `<key>_resourcepack` 형식으로 폴백.
|
||||
* 파일명으로 쓰기 전에 Windows 금지 문자(\<\>:"/\\|?*) 는 `_` 로 치환.
|
||||
*/
|
||||
outputPackName: string
|
||||
|
||||
@@ -3,17 +3,38 @@ import { promises as fs, createWriteStream, constants as fsConst } from 'node:fs
|
||||
import path from 'node:path'
|
||||
import https from 'node:https'
|
||||
import http from 'node:http'
|
||||
import { getMcCustomDir } from '../shared/paths.js'
|
||||
import { getMcCustomDir, getMcCustomInstallerDir } from '../shared/paths.js'
|
||||
import { loadComponentI18n } from '../shared/i18n.js'
|
||||
|
||||
const { t } = loadComponentI18n('installer-rp')
|
||||
|
||||
/**
|
||||
* 리소스팩 간편설치기는 Windows .exe 로 배포되므로 yt-dlp.exe 한 종류만 사용.
|
||||
* 경로: %appdata%/.mc_custom/yt-dlp.exe
|
||||
* 경로: %appdata%/.mc_custom/installer/yt-dlp.exe
|
||||
*/
|
||||
export function getYtDlpExePath(): string {
|
||||
return path.join(getMcCustomDir(), 'yt-dlp.exe')
|
||||
return path.join(getMcCustomInstallerDir(), 'yt-dlp.exe')
|
||||
}
|
||||
|
||||
/**
|
||||
* 0.2.1 이전 버전이 `.mc_custom/yt-dlp.exe` 에 받아둔 파일이 있으면 새 위치로
|
||||
* 옮긴다. 마인크래프트 게임 폴더 루트가 외부 도구 파일로 더럽혀지지 않도록.
|
||||
*/
|
||||
async function migrateLegacyExe(target: string): Promise<void> {
|
||||
const legacy = path.join(getMcCustomDir(), 'yt-dlp.exe')
|
||||
if (legacy === target) return
|
||||
try {
|
||||
await fs.access(legacy, fsConst.F_OK)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await fs.mkdir(path.dirname(target), { recursive: true })
|
||||
await fs.rename(legacy, target)
|
||||
} catch {
|
||||
// 권한·드라이브 문제 등으로 실패하면 그냥 새로 받으면 되므로 무시.
|
||||
try { await fs.unlink(legacy) } catch { /* noop */ }
|
||||
}
|
||||
}
|
||||
|
||||
const YT_DLP_DOWNLOAD_URL =
|
||||
@@ -29,6 +50,7 @@ export async function ensureYtDlpExe(
|
||||
log?: (line: string) => void
|
||||
): Promise<string> {
|
||||
const target = getYtDlpExePath()
|
||||
await migrateLegacyExe(target)
|
||||
if (await canExecute(target)) {
|
||||
log?.(t('log.ytdlpExists', { path: target }))
|
||||
return target
|
||||
|
||||
@@ -1128,41 +1128,49 @@ ipcMain.handle('client:install', async (_event, payload: ClientInstallPayload) =
|
||||
await fsp.mkdir(path.join(customRoot, 'mods'), { recursive: true })
|
||||
await fsp.mkdir(path.join(customRoot, 'resourcepacks'), { recursive: true })
|
||||
|
||||
// 사용자가 기존 .minecraft 에 저장해둔 설정(options.txt, servers.dat 등)을
|
||||
// .mc_custom 으로 가져온다. 이미 있는 파일은 보존.
|
||||
await copyMinecraftUserSettings(customRoot)
|
||||
try {
|
||||
// 사용자가 기존 .minecraft 에 저장해둔 설정(options.txt, servers.dat 등)을
|
||||
// .mc_custom 으로 가져온다. 이미 있는 파일은 보존.
|
||||
await copyMinecraftUserSettings(customRoot)
|
||||
|
||||
if (payload.installPlatform && pack.pack.platform.type === 'fabric') {
|
||||
await installFabricLoader(pack.pack, customRoot)
|
||||
} else if (payload.installPlatform && pack.pack.platform.type !== 'vanilla' && pack.pack.platform.downloadUrl) {
|
||||
const platformUrl = resolveManifestRelative(pack.pack.platform.downloadUrl, 'platforms')
|
||||
const cacheDir = path.join(customRoot, 'platform-cache')
|
||||
await fsp.mkdir(cacheDir, { recursive: true })
|
||||
const installerPath = path.join(cacheDir, deriveFileName(platformUrl) || 'platform-installer.jar')
|
||||
sendLog(t('log.platformDownload', { type: pack.pack.platform.type, url: platformUrl }))
|
||||
await downloadFile(platformUrl, installerPath)
|
||||
sendLog(t('log.platformSaved', { path: installerPath }))
|
||||
} else if (!payload.installPlatform) {
|
||||
sendLog(t('log.platformSkipped'))
|
||||
if (payload.installPlatform && pack.pack.platform.type === 'fabric') {
|
||||
await installFabricLoader(pack.pack, customRoot)
|
||||
} else if (payload.installPlatform && pack.pack.platform.type !== 'vanilla' && pack.pack.platform.downloadUrl) {
|
||||
const platformUrl = resolveManifestRelative(pack.pack.platform.downloadUrl, 'platforms')
|
||||
const cacheDir = path.join(customRoot, 'platform-cache')
|
||||
await fsp.mkdir(cacheDir, { recursive: true })
|
||||
const installerPath = path.join(cacheDir, deriveFileName(platformUrl) || 'platform-installer.jar')
|
||||
sendLog(t('log.platformDownload', { type: pack.pack.platform.type, url: platformUrl }))
|
||||
await downloadFile(platformUrl, installerPath)
|
||||
sendLog(t('log.platformSaved', { path: installerPath }))
|
||||
} else if (!payload.installPlatform) {
|
||||
sendLog(t('log.platformSkipped'))
|
||||
}
|
||||
|
||||
await downloadModsFolder(pack.pack, customRoot)
|
||||
await downloadResourcepackZip(pack.pack, customRoot)
|
||||
|
||||
if (payload.skipMap) {
|
||||
// 참가자 모드: 이전 설치 흐름에서 설치러가 풀어둔 맵이 있다면 제거한다.
|
||||
// 사용자가 직접 만든 월드는 마커에 포함되지 않으므로 그대로 보존된다.
|
||||
await cleanupInstallerMap(customRoot)
|
||||
sendLog(t('log.skipMapZip'))
|
||||
} else {
|
||||
await downloadMapZip(pack.pack, customRoot)
|
||||
}
|
||||
|
||||
// 런처가 .mc_custom 을 gameDir 로 잡아도 assets/libraries/versions 를
|
||||
// 찾을 수 있도록 .minecraft 의 해당 폴더로 junction 링크.
|
||||
await linkMinecraftRuntimeDirs(customRoot)
|
||||
|
||||
await updateLauncherProfile(pack.pack, customRoot)
|
||||
} finally {
|
||||
// 설치가 끝나면(또는 실패해도) 더 이상 필요 없는 platform-cache(다운받은
|
||||
// fabric/forge/neoforge installer jar 캐시)를 삭제한다. 다음 실행에서 다시
|
||||
// 받으면 되고, 남겨두면 사용자 .mc_custom 폴더만 차지한다. 실패 경로에서도
|
||||
// 정리되도록 finally 에 둔다.
|
||||
await fsp.rm(path.join(customRoot, 'platform-cache'), { recursive: true, force: true }).catch(() => {})
|
||||
}
|
||||
|
||||
await downloadModsFolder(pack.pack, customRoot)
|
||||
await downloadResourcepackZip(pack.pack, customRoot)
|
||||
|
||||
if (payload.skipMap) {
|
||||
// 참가자 모드: 이전 설치 흐름에서 설치러가 풀어둔 맵이 있다면 제거한다.
|
||||
// 사용자가 직접 만든 월드는 마커에 포함되지 않으므로 그대로 보존된다.
|
||||
await cleanupInstallerMap(customRoot)
|
||||
sendLog(t('log.skipMapZip'))
|
||||
} else {
|
||||
await downloadMapZip(pack.pack, customRoot)
|
||||
}
|
||||
|
||||
// 런처가 .mc_custom 을 gameDir 로 잡아도 assets/libraries/versions 를
|
||||
// 찾을 수 있도록 .minecraft 의 해당 폴더로 junction 링크.
|
||||
await linkMinecraftRuntimeDirs(customRoot)
|
||||
|
||||
await updateLauncherProfile(pack.pack, customRoot)
|
||||
})
|
||||
|
||||
interface FabricInstallerMeta {
|
||||
|
||||
@@ -32,3 +32,13 @@ export function getAppDataDir(): string {
|
||||
export function getMcCustomDir(): string {
|
||||
return path.join(getAppDataDir(), '.mc_custom')
|
||||
}
|
||||
|
||||
/**
|
||||
* %appdata%/.mc_custom/installer — 설치기가 자체적으로 다운로드해 사용하는
|
||||
* 외부 바이너리(yt-dlp.exe, ffmpeg.exe 등) 보관 위치. .mc_custom 루트가
|
||||
* 마인크래프트 게임 폴더(`mods/`, `resourcepacks/`, `saves/` 등)와 섞이지
|
||||
* 않도록 별도 하위 폴더에 둔다.
|
||||
*/
|
||||
export function getMcCustomInstallerDir(): string {
|
||||
return path.join(getMcCustomDir(), 'installer')
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface PackDefinition {
|
||||
resourcepackPath: string
|
||||
/**
|
||||
* 리소스팩 설치기가 만들어 내는 최종 zip 파일의 이름(확장자 제외).
|
||||
* 빈 문자열이면 설치기가 `<packKey>_musicquiz` 형식으로 기본 이름을 만든다.
|
||||
* 빈 문자열이면 설치기가 `<packKey>_resourcepack` 형식으로 기본 이름을 만든다.
|
||||
* 마인크래프트 리소스팩 목록에서 사용자에게 제목처럼 보이는 값이므로
|
||||
* 한글 등 자유 입력을 그대로 보존하고, 파일 시스템에서 사용할 때 금지 문자만
|
||||
* `_` 로 치환한다(치환 책임은 설치기 측에 있음).
|
||||
|
||||
Reference in New Issue
Block a user