Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f553f958d | |||
| 996a7cc03e | |||
| 00aa47ed17 | |||
| 9c2a92c101 | |||
| 662c3c7b23 | |||
| face70b3e9 | |||
| 651c63faa6 | |||
| f392842d7f | |||
| 00344084c7 | |||
| 704d58d3ac | |||
| 2212195b3c | |||
| 2fa1173b8e | |||
| 7b532d6520 | |||
| f0e07e06d6 |
@@ -31,6 +31,14 @@ SITE_BASE_URL=https://mq.example.com
|
||||
# 특별히 다른 경로를 쓰고 싶을 때만 아래를 풀어서 우선 적용시키세요.
|
||||
# MANIFEST_URL=https://mq.example.com/manifest.json
|
||||
|
||||
# ----- 커스텀 게임 폴더 이름 -----
|
||||
|
||||
# 음악퀴즈 전용 게임/캐시 폴더의 이름. %APPDATA% 바로 아래에 이 이름으로 생성됩니다.
|
||||
# 비워두면 기본값 `.mc_custom` 을 사용합니다. 경로 구분자(/ \)와 `..` 는 무시됩니다.
|
||||
# 설치기·리소스팩설치기·파일제거기가 모두 이 값을 공유하므로, 값을 바꾸면
|
||||
# 세 exe 를 같은 값으로 다시 빌드해야 서로 같은 폴더를 가리킵니다.
|
||||
# MC_CUSTOM_DIR=.mc_custom
|
||||
|
||||
# ----- 리소스팩 설치기 -----
|
||||
|
||||
# yt-dlp 동시 다운로드 수(1~8). 비워두면 CPU 코어 수로 자동 결정.
|
||||
|
||||
@@ -27,6 +27,12 @@ SITE_BASE_URL=http://127.0.0.1:3000
|
||||
# 특별히 다른 경로를 쓰고 싶을 때만 아래를 풀어서 우선 적용시키세요.
|
||||
# MANIFEST_URL=http://127.0.0.1:3000/manifest.json
|
||||
|
||||
# ----- 커스텀 게임 폴더 이름 -----
|
||||
|
||||
# 음악퀴즈 전용 게임/캐시 폴더의 이름. %APPDATA% 바로 아래에 이 이름으로 생성됩니다.
|
||||
# 비워두면 기본값 `.mc_custom` 을 사용합니다. 경로 구분자(/ \)와 `..` 는 무시됩니다.
|
||||
# MC_CUSTOM_DIR=.mc_custom
|
||||
|
||||
# ----- 리소스팩 설치기 -----
|
||||
|
||||
# yt-dlp 동시 다운로드 수(1~8). 비워두면 CPU 코어 수로 자동 결정.
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -7,3 +7,7 @@ conversations/
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
# 세션 서명용 자동 생성 시크릿. 절대 커밋 금지.
|
||||
.session-secret
|
||||
# 운영 계정(해시 비밀번호) 파일. 추적되는 account.json 대신 이 파일을 사용. 커밋 금지.
|
||||
account.local.json
|
||||
|
||||
39
README.md
39
README.md
@@ -5,6 +5,8 @@
|
||||
- **관리 사이트** — 음악퀴즈 정보(JSON)와 음악·사진 목록, 데이터팩 출력을 한 곳에서 운영.
|
||||
- **음악퀴즈 간편설치기 (`.exe`)** — `manifest.json` 기반으로 사용자가 마인크래프트 본체·서버·모드를 자동 설치.
|
||||
- **리소스팩 간편설치기 (`.exe`)** — 음악퀴즈 음악·표지를 yt-dlp 로 받아 painting variant 텍스처 리소스팩으로 패키징.
|
||||
- **간편포트포워딩 (`.exe`)** — 원하는 포트를 입력해 UPnP 로 개방. 프로그램을 켜 두는 동안만 열려 있고 창을 닫으면 자동으로 닫힙니다.
|
||||
- **음악퀴즈 파일제거 (`.exe`)** — 설치기들이 만든 게임 폴더·캐시와 런처 프로필을 휴지통 이동 또는 완전 삭제로 한 번에 정리.
|
||||
|
||||
---
|
||||
|
||||
@@ -15,7 +17,9 @@
|
||||
| `src/server/` | 음악퀴즈 관리 웹사이트 (Express + EJS) | `bun start` 또는 `npm start` |
|
||||
| `src/installer/` | 음악퀴즈 간편설치기 (Electron) | `npm run installer` |
|
||||
| `src/installer-rp/` | 리소스팩 간편설치기 (Electron) | `npm run installer:rp` |
|
||||
| `src/shared/` | 두 설치기와 서버가 공유하는 타입·스토어 | — |
|
||||
| `src/installer-pf/` | 간편포트포워딩 도구 (Electron) | `npm run installer:pf` |
|
||||
| `src/installer-uninstall/` | 음악퀴즈 파일제거 도구 (Electron) | `npm run installer:uninstall` |
|
||||
| `src/shared/` | 설치기들과 서버가 공유하는 타입·스토어 | — |
|
||||
| `views/` | EJS 템플릿 (관리 사이트) | — |
|
||||
| `manifest/` | 음악퀴즈별 정의 JSON | — |
|
||||
| `file/list/` | 음악퀴즈별 음악·사진 목록 JSON | — |
|
||||
@@ -43,6 +47,8 @@
|
||||
|
||||
이렇게 분리해 두면 사용자가 평소 쓰던 마인크래프트와 음악퀴즈 설정이 섞이지 않고, 음악퀴즈만 삭제해도 본체에는 영향이 없습니다.
|
||||
|
||||
> **폴더 이름 바꾸기.** 기본값은 `.mc_custom` 이지만 `.env` / `.env.build` 의 `MC_CUSTOM_DIR` 로 다른 이름을 지정할 수 있습니다. 설치기·리소스팩설치기·파일제거기가 모두 이 값을 공유하므로, 값을 바꾸면 세 exe 를 같은 값으로 다시 빌드해야 서로 같은 폴더를 가리킵니다. (경로 구분자 `/ \` 와 `..` 는 무시되어 항상 `%APPDATA%` 바로 아래 단일 폴더가 됩니다.)
|
||||
|
||||
---
|
||||
|
||||
## 빠른 시작
|
||||
@@ -65,8 +71,17 @@ npm run installer
|
||||
# 3) 리소스팩 간편설치기를 Electron 으로 실행해 보기
|
||||
npm run installer:rp
|
||||
|
||||
# 4) 음악퀴즈 간편설치기 윈도우 .exe 빌드
|
||||
npm run dist:win
|
||||
# 4) 간편포트포워딩 / 파일제거 도구 실행해 보기
|
||||
npm run installer:pf
|
||||
npm run installer:uninstall
|
||||
|
||||
# 5) 윈도우 .exe 빌드 (개별)
|
||||
npm run dist:win # 음악퀴즈 간편설치기
|
||||
npm run dist:win:rp # 음악퀴즈 리소스팩설치기
|
||||
npm run dist:win:pf # 간편포트포워딩
|
||||
npm run dist:win:uninstall # 음악퀴즈 파일제거
|
||||
npm run dist:win:dev # (개발자용) 음악퀴즈 간편설치기
|
||||
npm run dist:win:rp:dev # (개발자용) 음악퀴즈 리소스팩설치기
|
||||
```
|
||||
|
||||
리소스팩 설치기는 `yt-dlp` 가 필요합니다. 자동 다운로드되지만, 막혀 있는 환경이라면 [`docs/yt-dlp-setup.md`](docs/yt-dlp-setup.md) 참고.
|
||||
@@ -155,9 +170,13 @@ minecraft_launcher/
|
||||
│ ├─ server/ Express + EJS 관리 사이트
|
||||
│ ├─ installer/ 음악퀴즈 간편설치기 (Electron 메인 + preload)
|
||||
│ ├─ installer-rp/ 리소스팩 간편설치기 (Electron 메인 + 음악/이미지 파이프라인)
|
||||
│ ├─ installer-pf/ 간편포트포워딩 도구 (Electron 메인 + preload)
|
||||
│ ├─ installer-uninstall/ 음악퀴즈 파일제거 도구 (Electron 메인 + preload)
|
||||
│ └─ shared/ 공용 타입, 매니페스트 스토어, mojang/upnp 유틸
|
||||
├─ installer/ 음악퀴즈 설치기 렌더러(HTML/CSS/JS)
|
||||
├─ installer-rp/ 리소스팩 설치기 렌더러(HTML/CSS/JS)
|
||||
├─ installer-pf/ 간편포트포워딩 렌더러(HTML/JS)
|
||||
├─ installer-uninstall/ 파일제거 렌더러(HTML/JS)
|
||||
├─ views/ 관리 사이트 EJS 템플릿
|
||||
├─ public/ 관리 사이트 정적 파일(styles.css 등)
|
||||
├─ manifest/ 음악퀴즈 JSON 정의 (운영자가 편집)
|
||||
@@ -172,18 +191,24 @@ minecraft_launcher/
|
||||
├─ manifest.json 사이트 루트 매니페스트 (자동 관리)
|
||||
├─ account.json 관리자 계정 (절대 외부 노출 금지)
|
||||
├─ package.json
|
||||
└─ tsconfig.{,server,installer,installer-rp}.json
|
||||
└─ tsconfig.{,server,installer,installer-rp,installer-pf,installer-uninstall}.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 빌드 산출물 / 배포
|
||||
|
||||
| 산출물 | 빌드 명령 | 비고 |
|
||||
| 산출물(파일명) | 빌드 명령 | 비고 |
|
||||
| --- | --- | --- |
|
||||
| 관리 사이트 (Node 실행) | `npm start` | systemd 등으로 띄우기. 외부 도메인이 manifest 의 base URL 이 됩니다. |
|
||||
| 음악퀴즈 간편설치기 `.exe` | `npm run dist:win` | `electron-builder.yml` 설정 사용. |
|
||||
| 리소스팩 간편설치기 `.exe` | `tsconfig.installer-rp.json` 빌드 후 `electron-builder` 수동 패키징 | |
|
||||
| `음악퀴즈 간편설치기-<버전>.exe` | `npm run dist:win` | `electron-builder.yml`. |
|
||||
| `음악퀴즈 리소스팩설치기-<버전>.exe` | `npm run dist:win:rp` | `electron-builder-rp.yml`. |
|
||||
| `간편포트포워딩-<버전>.exe` | `npm run dist:win:pf` | `electron-builder-pf.yml`. |
|
||||
| `음악퀴즈 파일제거-<버전>.exe` | `npm run dist:win:uninstall` | `electron-builder-uninstall.yml`. |
|
||||
| `(개발자용) 음악퀴즈 간편설치기-<버전>.exe` | `npm run dist:win:dev` | 비공개(public=false) 팩만 노출. 제목 앞에 `(개발자용)` 표시. |
|
||||
| `(개발자용) 음악퀴즈 리소스팩설치기-<버전>.exe` | `npm run dist:win:rp:dev` | 상동. |
|
||||
|
||||
빌드 결과물은 `release/` 폴더에 생성됩니다(포터블 exe).
|
||||
|
||||
---
|
||||
|
||||
|
||||
3
account.example.json
Normal file
3
account.example.json
Normal file
@@ -0,0 +1,3 @@
|
||||
[
|
||||
{ "id": "admin", "password": "여기에-비밀번호를-넣으세요" }
|
||||
]
|
||||
@@ -50,7 +50,9 @@ npm start # 기본 포트 3000.
|
||||
|
||||
## 계정
|
||||
|
||||
`account.json` 에 정의합니다(루트 디렉터리). **외부 HTTP 로 절대 노출되지 않도록 라우팅에서 제외돼 있습니다.**
|
||||
운영 계정은 **gitignore 된 `account.local.json`**(루트 디렉터리, 0600, scrypt 해시)에 저장됩니다. 추적되는 `account.json` 은 서버에 `account.local.json` 이 없을 때만 읽는 **시드 소스**로, 서버 시작 시 자동으로 `account.local.json`(0600) 으로 복사됩니다. 두 파일 모두 **외부 HTTP 로 절대 노출되지 않도록 라우팅에서 제외돼 있습니다.**
|
||||
|
||||
시드 포맷(`account.json`):
|
||||
|
||||
```json
|
||||
[
|
||||
@@ -58,7 +60,7 @@ npm start # 기본 포트 3000.
|
||||
]
|
||||
```
|
||||
|
||||
> 운영 환경에서는 평문 비밀번호 대신 해시를 쓰도록 추후 보강할 여지가 있습니다.
|
||||
평문 비밀번호로 시드해도 로그인 성공 시 자동으로 scrypt 해시(`scrypt$<salt>$<hash>`)로 업그레이드되어 `account.local.json` 에만 저장됩니다. 자세한 마이그레이션 절차는 아래 "운영 계정 파일 마이그레이션" 을 참고하세요.
|
||||
|
||||
## 대시보드 (`/op/dashboard`)
|
||||
|
||||
@@ -138,4 +140,14 @@ say [musicquiz] 데이터팩 초기화
|
||||
|
||||
- `account.json` 은 라우팅에서 차단되어 있으나, 디스크 권한도 운영자만 접근 가능하게 두는 것이 안전합니다.
|
||||
- 관리자 비밀번호는 충분히 강하게 설정.
|
||||
|
||||
### 운영 계정 파일 마이그레이션 (미완결 — 재배포 게이트)
|
||||
|
||||
운영 계정은 이제 gitignore 된 `account.local.json`(0o600, scrypt 해시)에만 저장됩니다. 추적되는 `account.json` 은 서버에 `account.local.json` 이 없을 때만 읽는 **시드 소스**로 남겨 둔 상태입니다. 남은 위생 작업이 하나 있습니다:
|
||||
|
||||
1. **[운영] 최신 main 재배포** → 서버가 `account.local.json`(0o600) 을 자동 생성하는지 확인.
|
||||
2. **[운영] 비밀번호 로테이션** — git 히스토리에 평문 비밀번호가 남아 있어 추적 해제로는 지워지지 않으므로, 이것이 실질적 최우선 보안 조치입니다.
|
||||
3. **[후속 커밋] `account.json` 추적 해제** — 위 1번(서버에 `account.local.json` 존재) 확인 **후에만** `git rm --cached account.json` 를 별도 커밋으로 진행. 같은 커밋에서 하면 시드 소스가 사라져 로그인이 막힙니다.
|
||||
|
||||
> 코드 상 앵커: `src/shared/paths.ts` 의 `TODO(untrack-after-redeploy)` 주석.
|
||||
- 모든 `/op/*` 라우트는 세션 기반 인증 미들웨어를 거칩니다. 세션 만료 시 자동으로 로그인 페이지로 리다이렉트.
|
||||
|
||||
35
electron-builder-dev.yml
Normal file
35
electron-builder-dev.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
appId: kr.tkrmagid.musicquiz.installer.dev
|
||||
productName: MusicQuizInstaller
|
||||
# 개발자용 빌드: manifest 의 public===false 인 pack 만 노출한다.
|
||||
# musicQuizAudience 를 package.json 에 박아 런타임에서 대상(audience)을 판별.
|
||||
extraMetadata:
|
||||
main: dist/installer/main.js
|
||||
musicQuizAudience: developer
|
||||
directories:
|
||||
output: release
|
||||
buildResources: build
|
||||
files:
|
||||
- dist/installer/**
|
||||
- dist/shared/**
|
||||
- installer/**
|
||||
- build/icon.*
|
||||
- package.json
|
||||
- "!node_modules/@img/sharp-linux-*"
|
||||
- "!node_modules/@img/sharp-linuxmusl-*"
|
||||
- "!node_modules/@img/sharp-libvips-linux-*"
|
||||
- "!node_modules/@img/sharp-libvips-linuxmusl-*"
|
||||
extraResources:
|
||||
- from: .
|
||||
to: .
|
||||
filter:
|
||||
- .env.build
|
||||
- from: locales
|
||||
to: locales
|
||||
filter:
|
||||
- "**/*"
|
||||
win:
|
||||
target: portable
|
||||
artifactName: (개발자용) 음악퀴즈 간편설치기-${version}.${ext}
|
||||
icon: build/icon.ico
|
||||
portable:
|
||||
artifactName: (개발자용) 음악퀴즈 간편설치기-${version}.${ext}
|
||||
@@ -27,7 +27,7 @@ extraResources:
|
||||
- "**/*"
|
||||
win:
|
||||
target: portable
|
||||
artifactName: 마인크래프트간편포트포워딩-${version}-Portable.${ext}
|
||||
artifactName: 간편포트포워딩-${version}.${ext}
|
||||
icon: build/icon.ico
|
||||
portable:
|
||||
artifactName: 마인크래프트간편포트포워딩-${version}-Portable.${ext}
|
||||
artifactName: 간편포트포워딩-${version}.${ext}
|
||||
|
||||
35
electron-builder-rp-dev.yml
Normal file
35
electron-builder-rp-dev.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
appId: kr.tkrmagid.musicquiz.installer-rp.dev
|
||||
productName: MusicQuizResourcepackInstaller
|
||||
# 개발자용 리소스팩 설치기: manifest 의 public===false 인 pack 만 노출.
|
||||
extraMetadata:
|
||||
main: dist/installer-rp/main.js
|
||||
musicQuizAudience: developer
|
||||
directories:
|
||||
output: release
|
||||
buildResources: build
|
||||
files:
|
||||
- dist/installer-rp/**
|
||||
- dist/shared/**
|
||||
- installer-rp/**
|
||||
- installer/styles.css
|
||||
- build/icon.*
|
||||
- package.json
|
||||
- "!node_modules/@img/sharp-linux-*"
|
||||
- "!node_modules/@img/sharp-linuxmusl-*"
|
||||
- "!node_modules/@img/sharp-libvips-linux-*"
|
||||
- "!node_modules/@img/sharp-libvips-linuxmusl-*"
|
||||
extraResources:
|
||||
- from: .
|
||||
to: .
|
||||
filter:
|
||||
- .env.build
|
||||
- from: locales
|
||||
to: locales
|
||||
filter:
|
||||
- "**/*"
|
||||
win:
|
||||
target: portable
|
||||
artifactName: (개발자용) 음악퀴즈 리소스팩설치기-${version}.${ext}
|
||||
icon: build/icon.ico
|
||||
portable:
|
||||
artifactName: (개발자용) 음악퀴즈 리소스팩설치기-${version}.${ext}
|
||||
@@ -35,7 +35,7 @@ extraResources:
|
||||
- "**/*"
|
||||
win:
|
||||
target: portable
|
||||
artifactName: ${productName}-${version}-Portable.${ext}
|
||||
artifactName: 음악퀴즈 리소스팩설치기-${version}.${ext}
|
||||
icon: build/icon.ico
|
||||
portable:
|
||||
artifactName: ${productName}-${version}-Portable.${ext}
|
||||
artifactName: 음악퀴즈 리소스팩설치기-${version}.${ext}
|
||||
|
||||
38
electron-builder-uninstall.yml
Normal file
38
electron-builder-uninstall.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
appId: kr.tkrmagid.musicquiz.uninstall
|
||||
productName: 음악퀴즈 파일제거
|
||||
# 루트 package.json 의 "main" 은 메인 설치기를 가리키므로, 패키지된 앱이
|
||||
# 파일제거 도구를 진입점으로 쓰도록 빌드 시 main 을 덮어쓴다.
|
||||
extraMetadata:
|
||||
main: dist/installer-uninstall/main.js
|
||||
directories:
|
||||
output: release
|
||||
buildResources: build
|
||||
files:
|
||||
- dist/installer-uninstall/**
|
||||
- dist/shared/**
|
||||
- installer-uninstall/**
|
||||
# index.html 은 메인 설치기와 동일한 styles.css 를 공유함
|
||||
# (`<link href="../installer/styles.css">`). 그 한 파일만 명시적으로 포함.
|
||||
- installer/styles.css
|
||||
- build/icon.*
|
||||
- package.json
|
||||
# 이 도구는 sharp(이미지 처리)를 쓰지 않으므로 통째로 제외해 exe 크기를 줄인다.
|
||||
- "!node_modules/sharp/**"
|
||||
- "!node_modules/@img/**"
|
||||
# MC_CUSTOM_DIR 을 커스텀으로 빌드했다면 파일제거기도 같은 폴더를 가리켜야 하므로
|
||||
# `.env.build` 를 함께 배포한다. i18n 사전(locales/installer-uninstall/ko-kr.json)도 함께.
|
||||
extraResources:
|
||||
- from: .
|
||||
to: .
|
||||
filter:
|
||||
- .env.build
|
||||
- from: locales
|
||||
to: locales
|
||||
filter:
|
||||
- "**/*"
|
||||
win:
|
||||
target: portable
|
||||
artifactName: 음악퀴즈 파일제거-${version}.${ext}
|
||||
icon: build/icon.ico
|
||||
portable:
|
||||
artifactName: 음악퀴즈 파일제거-${version}.${ext}
|
||||
@@ -32,7 +32,7 @@ extraResources:
|
||||
- "**/*"
|
||||
win:
|
||||
target: portable
|
||||
artifactName: ${productName}-${version}-Portable.${ext}
|
||||
artifactName: 음악퀴즈 간편설치기-${version}.${ext}
|
||||
icon: build/icon.ico
|
||||
portable:
|
||||
artifactName: ${productName}-${version}-Portable.${ext}
|
||||
artifactName: 음악퀴즈 간편설치기-${version}.${ext}
|
||||
|
||||
@@ -189,76 +189,110 @@ function showAgreementError(message) {
|
||||
section.querySelector('#retry').addEventListener('click', renderAgreement)
|
||||
}
|
||||
|
||||
// 약관을 한 건씩 페이지로 보여준다. 각 약관마다 "해당 약관에 동의합니다" 체크가 있고,
|
||||
// 끝까지 스크롤해 읽어야 체크할 수 있으며, [다음] 을 누르면 다음 약관 페이지가 화면
|
||||
// 맨 위에서부터 나온다. 마지막 약관까지 동의하면 다음 단계(step2)로 진행한다.
|
||||
function renderAgreementWithKinds(KINDS) {
|
||||
var idx = 0
|
||||
var accepted = {} // kind -> true (뒤로 갔다 와도 동의 상태 유지)
|
||||
var cache = {} // kind -> 렌더된 HTML
|
||||
|
||||
var section = document.createElement('section')
|
||||
section.className = 'page'
|
||||
section.innerHTML =
|
||||
'<h2>' + escapeHtml(tt('agreement.heading')) + '</h2>' +
|
||||
'<p class="formMessage">' + escapeHtml(tt('agreement.intro')) + '</p>' +
|
||||
'<div class="tabBar" id="agTabs">' +
|
||||
KINDS.map(function (k, i) {
|
||||
return '<button type="button" class="tabBtn' + (i === 0 ? ' active' : '') + '" data-ag="' + k.id + '">' + escapeHtml(k.tab) + '</button>'
|
||||
}).join('') +
|
||||
'</div>' +
|
||||
'<div class="agreementBody" id="agBody">' + escapeHtml(tt('agreement.loading')) + '</div>' +
|
||||
'<label class="toggleRow" style="margin-top:12px;"><input type="checkbox" id="agAccept" /> ' +
|
||||
escapeHtml(tt('agreement.agreeAll')) + '</label>' +
|
||||
'<div class="formMessage" id="agMsg"></div>' +
|
||||
'<div class="actionRow">' +
|
||||
' <button class="secondaryBtn" id="back">' + escapeHtml(tt('common.back')) + '</button>' +
|
||||
' <button class="primaryBtn" id="next" disabled>' + escapeHtml(tt('common.next')) + '</button>' +
|
||||
'</div>'
|
||||
pageHost.appendChild(section)
|
||||
|
||||
var body = section.querySelector('#agBody')
|
||||
var tabs = section.querySelectorAll('[data-ag]')
|
||||
var nextBtn = section.querySelector('#next')
|
||||
var accept = section.querySelector('#agAccept')
|
||||
var msg = section.querySelector('#agMsg')
|
||||
function renderCurrent() {
|
||||
var k = KINDS[idx]
|
||||
var isLast = idx === KINDS.length - 1
|
||||
section.innerHTML =
|
||||
'<h2>' + escapeHtml(tt('agreement.heading')) + '</h2>' +
|
||||
'<p class="formMessage">' + escapeHtml(tt('agreement.stepLabel', { current: idx + 1, total: KINDS.length, label: k.tab })) + '</p>' +
|
||||
'<div class="agreementBody" id="agBody" style="border-radius:10px;">' + escapeHtml(tt('agreement.loading')) + '</div>' +
|
||||
'<div class="formMessage" id="agHint">' + escapeHtml(tt('agreement.readToBottom')) + '</div>' +
|
||||
'<label class="toggleRow" style="margin-top:8px;"><input type="checkbox" id="agAccept" disabled /> ' +
|
||||
escapeHtml(tt('agreement.agreeThis')) + '</label>' +
|
||||
'<div class="formMessage" id="agMsg"></div>' +
|
||||
'<div class="actionRow">' +
|
||||
' <button class="secondaryBtn" id="back">' + escapeHtml(tt('common.back')) + '</button>' +
|
||||
' <button class="primaryBtn" id="next" disabled>' + escapeHtml(tt('common.next')) + '</button>' +
|
||||
'</div>'
|
||||
|
||||
// 본문 캐시. 탭 전환 시 재요청하지 않음.
|
||||
var cache = {}
|
||||
var body = section.querySelector('#agBody')
|
||||
var accept = section.querySelector('#agAccept')
|
||||
var nextBtn = section.querySelector('#next')
|
||||
var msg = section.querySelector('#agMsg')
|
||||
var hint = section.querySelector('#agHint')
|
||||
|
||||
function showKind(kind) {
|
||||
if (cache[kind]) { body.innerHTML = cache[kind]; return }
|
||||
body.textContent = tt('agreement.loading')
|
||||
api.getTerm(kind).then(function (res) {
|
||||
if (!res.ok) {
|
||||
body.innerHTML = '<p class="formMessage error">' + escapeHtml(tt('agreement.loadFailed', { message: res.message || '' })) + '</p>'
|
||||
// 새 약관 페이지는 화면 맨 위에서부터 보이도록 스크롤을 올린다.
|
||||
if (pageHost) pageHost.scrollTop = 0
|
||||
|
||||
function markReadable() {
|
||||
if (!accept.disabled) return
|
||||
accept.disabled = false
|
||||
hint.textContent = ''
|
||||
}
|
||||
function checkScrolled() {
|
||||
if (body.scrollHeight - body.scrollTop - body.clientHeight <= 6) markReadable()
|
||||
}
|
||||
body.addEventListener('scroll', checkScrolled)
|
||||
|
||||
accept.addEventListener('change', function () {
|
||||
accepted[k.id] = accept.checked
|
||||
nextBtn.disabled = !accept.checked
|
||||
if (accept.checked) { msg.textContent = ''; msg.classList.remove('error') }
|
||||
})
|
||||
|
||||
nextBtn.addEventListener('click', function () {
|
||||
if (!accept.checked) {
|
||||
msg.textContent = tt('agreement.agreeRequired')
|
||||
msg.classList.add('error')
|
||||
return
|
||||
}
|
||||
var html = renderTermsMarkdown(res.content || '')
|
||||
cache[kind] = html
|
||||
body.innerHTML = html
|
||||
}).catch(function (err) {
|
||||
body.innerHTML = '<p class="formMessage error">' + escapeHtml(tt('agreement.loadFailed', { message: err.message })) + '</p>'
|
||||
if (isLast) renderStep2()
|
||||
else { idx++; renderCurrent() }
|
||||
})
|
||||
section.querySelector('#back').addEventListener('click', function () {
|
||||
if (idx === 0) renderStep1()
|
||||
else { idx--; renderCurrent() }
|
||||
})
|
||||
|
||||
function afterLoad() {
|
||||
body.scrollTop = 0
|
||||
if (accepted[k.id]) {
|
||||
accept.disabled = false
|
||||
accept.checked = true
|
||||
nextBtn.disabled = false
|
||||
hint.textContent = ''
|
||||
}
|
||||
setTimeout(function () {
|
||||
if (body.scrollHeight - body.clientHeight <= 6) markReadable()
|
||||
else checkScrolled()
|
||||
}, 0)
|
||||
}
|
||||
|
||||
if (cache[k.id]) {
|
||||
body.innerHTML = cache[k.id]
|
||||
afterLoad()
|
||||
} else {
|
||||
body.textContent = tt('agreement.loading')
|
||||
api.getTerm(k.id).then(function (res) {
|
||||
if (!res.ok) {
|
||||
body.innerHTML = '<p class="formMessage error">' + escapeHtml(tt('agreement.loadFailed', { message: res.message || '' })) + '</p>'
|
||||
markReadable()
|
||||
return
|
||||
}
|
||||
var html = renderTermsMarkdown(res.content || '')
|
||||
cache[k.id] = html
|
||||
body.innerHTML = html
|
||||
afterLoad()
|
||||
}).catch(function (err) {
|
||||
body.innerHTML = '<p class="formMessage error">' + escapeHtml(tt('agreement.loadFailed', { message: err.message })) + '</p>'
|
||||
markReadable()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
tabs.forEach(function (b) {
|
||||
b.addEventListener('click', function () {
|
||||
tabs.forEach(function (x) { x.classList.remove('active') })
|
||||
b.classList.add('active')
|
||||
showKind(b.getAttribute('data-ag'))
|
||||
})
|
||||
})
|
||||
|
||||
accept.addEventListener('change', function () {
|
||||
nextBtn.disabled = !accept.checked
|
||||
if (accept.checked) msg.textContent = ''
|
||||
})
|
||||
|
||||
nextBtn.addEventListener('click', function () {
|
||||
if (!accept.checked) {
|
||||
msg.textContent = tt('agreement.agreeRequired')
|
||||
msg.classList.add('error')
|
||||
return
|
||||
}
|
||||
renderStep2()
|
||||
})
|
||||
section.querySelector('#back').addEventListener('click', renderStep1)
|
||||
|
||||
showKind(KINDS[0].id)
|
||||
renderCurrent()
|
||||
}
|
||||
|
||||
// 인스톨러용 미니 markdown 렌더러. 사이트 termsEditor 와 같은 규칙을 처리한다.
|
||||
|
||||
22
installer-uninstall/index.html
Normal file
22
installer-uninstall/index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>음악퀴즈 파일제거</title>
|
||||
<link rel="stylesheet" href="../installer/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header class="appHeader">
|
||||
<h1>음악퀴즈 파일제거</h1>
|
||||
</header>
|
||||
|
||||
<main id="pageHost"></main>
|
||||
|
||||
<aside class="logViewer" id="logViewer" hidden>
|
||||
<header><h2>로그</h2><button type="button" id="logToggle">접기</button></header>
|
||||
<pre id="logBody"></pre>
|
||||
</aside>
|
||||
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
209
installer-uninstall/renderer.js
Normal file
209
installer-uninstall/renderer.js
Normal file
@@ -0,0 +1,209 @@
|
||||
'use strict'
|
||||
|
||||
const api = window.uninstaller
|
||||
|
||||
let I18N = {}
|
||||
|
||||
function tt(key, params) {
|
||||
var parts = String(key).split('.')
|
||||
var cur = I18N
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
if (cur && typeof cur === 'object' && parts[i] in cur) {
|
||||
cur = cur[parts[i]]
|
||||
} else {
|
||||
return key
|
||||
}
|
||||
}
|
||||
if (typeof cur !== 'string') return key
|
||||
if (!params) return cur
|
||||
return cur.replace(/\{\{\s*(\w+)\s*\}\}/g, function (_m, name) {
|
||||
return name in params ? String(params[name]) : '{{' + name + '}}'
|
||||
})
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
return String(s).replace(/[&<>"']/g, function (c) {
|
||||
return c === '&' ? '&' : c === '<' ? '<' : c === '>' ? '>' : c === '"' ? '"' : '''
|
||||
})
|
||||
}
|
||||
|
||||
const pageHost = document.getElementById('pageHost')
|
||||
const logViewer = document.getElementById('logViewer')
|
||||
const logBody = document.getElementById('logBody')
|
||||
const logToggle = document.getElementById('logToggle')
|
||||
|
||||
logToggle.addEventListener('click', function () {
|
||||
logViewer.classList.toggle('collapsed')
|
||||
if (logViewer.classList.contains('collapsed')) {
|
||||
logViewer.style.height = '36px'
|
||||
logToggle.textContent = tt('logViewer.expand')
|
||||
} else {
|
||||
logViewer.style.height = ''
|
||||
logToggle.textContent = tt('logViewer.collapse')
|
||||
}
|
||||
})
|
||||
|
||||
api.onLog(function (line) {
|
||||
logViewer.hidden = false
|
||||
logBody.textContent += line + '\n'
|
||||
logBody.scrollTop = logBody.scrollHeight
|
||||
})
|
||||
|
||||
function applyStaticI18n() {
|
||||
document.title = tt('app.title')
|
||||
var h1 = document.querySelector('.appHeader h1')
|
||||
if (h1) h1.textContent = tt('app.title')
|
||||
var logH2 = logViewer.querySelector('header h2')
|
||||
if (logH2) logH2.textContent = tt('logViewer.heading')
|
||||
logToggle.textContent = tt('logViewer.collapse')
|
||||
}
|
||||
|
||||
// ── 1단계: 삭제 동의 ──────────────────────────────
|
||||
function renderConfirm() {
|
||||
pageHost.innerHTML =
|
||||
'<section class="page">' +
|
||||
' <h2>' + escapeHtml(tt('confirm.heading')) + '</h2>' +
|
||||
' <p class="formMessage" style="margin-top:8px;font-size:15px;">' + escapeHtml(tt('confirm.question')) + '</p>' +
|
||||
' <p class="formMessage" style="margin-top:8px;">' + escapeHtml(tt('confirm.detail')) + '</p>' +
|
||||
' <div id="previewBox" class="progressCard" style="margin-top:14px;"><p class="formMessage">' +
|
||||
escapeHtml(tt('confirm.loadingPreview')) + '</p></div>' +
|
||||
' <div class="actionRow" style="margin-top:16px;">' +
|
||||
' <button class="primaryBtn" id="agreeBtn" disabled>' + escapeHtml(tt('confirm.agreeBtn')) + '</button>' +
|
||||
' <button class="secondaryBtn" id="cancelBtn">' + escapeHtml(tt('confirm.cancelBtn')) + '</button>' +
|
||||
' </div>' +
|
||||
'</section>'
|
||||
|
||||
var agreeBtn = document.getElementById('agreeBtn')
|
||||
var cancelBtn = document.getElementById('cancelBtn')
|
||||
var previewBox = document.getElementById('previewBox')
|
||||
|
||||
cancelBtn.addEventListener('click', function () { api.quit() })
|
||||
|
||||
api.preview().then(function (p) {
|
||||
var existingDirs = p.existingDirs || []
|
||||
var items = []
|
||||
if (existingDirs.length) {
|
||||
for (var d = 0; d < existingDirs.length; d++) {
|
||||
items.push(tt('confirm.itemCustomDir', { path: existingDirs[d] }))
|
||||
}
|
||||
} else {
|
||||
var first = (p.allTargetDirs && p.allTargetDirs[0]) || ''
|
||||
items.push(tt('confirm.itemCustomDirMissing', { path: first }))
|
||||
}
|
||||
if (p.shortcutExists) items.push(tt('confirm.itemShortcut'))
|
||||
if (p.launcherProfiles && p.launcherProfiles.length) {
|
||||
items.push(tt('confirm.itemProfiles', { names: p.launcherProfiles.join(', ') }))
|
||||
}
|
||||
var nothing = !existingDirs.length && !p.shortcutExists && (!p.launcherProfiles || !p.launcherProfiles.length)
|
||||
var html = '<p class="formMessage"><strong>' + escapeHtml(tt('confirm.previewTitle')) + '</strong></p><ul>'
|
||||
for (var i = 0; i < items.length; i++) html += '<li>' + escapeHtml(items[i]) + '</li>'
|
||||
html += '</ul>'
|
||||
if (nothing) html += '<p class="formMessage">' + escapeHtml(tt('confirm.nothingFound')) + '</p>'
|
||||
previewBox.innerHTML = html
|
||||
agreeBtn.disabled = false
|
||||
agreeBtn.addEventListener('click', function () { renderChoose(p) })
|
||||
}).catch(function (err) {
|
||||
previewBox.innerHTML = '<p class="formMessage error">' +
|
||||
escapeHtml(tt('confirm.previewFail', { message: (err && err.message) || String(err) })) + '</p>'
|
||||
agreeBtn.disabled = false
|
||||
agreeBtn.addEventListener('click', function () { renderChoose({ existingDirs: [], allTargetDirs: [], shortcutExists: false, launcherProfiles: [] }) })
|
||||
})
|
||||
}
|
||||
|
||||
// ── 2단계: 삭제 방식 선택 ─────────────────────────
|
||||
function renderChoose(preview) {
|
||||
pageHost.innerHTML =
|
||||
'<section class="page">' +
|
||||
' <h2>' + escapeHtml(tt('choose.heading')) + '</h2>' +
|
||||
' <p class="formMessage" style="margin-top:8px;">' + escapeHtml(tt('choose.intro')) + '</p>' +
|
||||
' <div class="actionRow" style="margin-top:18px;flex-direction:column;gap:12px;align-items:stretch;">' +
|
||||
' <button class="secondaryBtn" id="trashBtn" style="padding:16px;text-align:left;">' +
|
||||
' <strong>' + escapeHtml(tt('choose.trashTitle')) + '</strong><br/>' +
|
||||
' <span class="formMessage">' + escapeHtml(tt('choose.trashDesc')) + '</span></button>' +
|
||||
' <button class="secondaryBtn" id="permBtn" style="padding:16px;text-align:left;">' +
|
||||
' <strong>' + escapeHtml(tt('choose.permTitle')) + '</strong><br/>' +
|
||||
' <span class="formMessage">' + escapeHtml(tt('choose.permDesc')) + '</span></button>' +
|
||||
' </div>' +
|
||||
' <div class="actionRow" style="margin-top:16px;">' +
|
||||
' <button class="secondaryBtn" id="backBtn">' + escapeHtml(tt('choose.backBtn')) + '</button>' +
|
||||
' </div>' +
|
||||
' <div id="runState"></div>' +
|
||||
'</section>'
|
||||
|
||||
var trashBtn = document.getElementById('trashBtn')
|
||||
var permBtn = document.getElementById('permBtn')
|
||||
var backBtn = document.getElementById('backBtn')
|
||||
var runState = document.getElementById('runState')
|
||||
|
||||
backBtn.addEventListener('click', function () { renderConfirm() })
|
||||
|
||||
function runMode(mode) {
|
||||
var warn = mode === 'permanent' ? tt('choose.confirmPermanent') : tt('choose.confirmTrash')
|
||||
if (!window.confirm(warn)) return
|
||||
trashBtn.disabled = true
|
||||
permBtn.disabled = true
|
||||
backBtn.disabled = true
|
||||
runState.innerHTML = '<p class="formMessage" style="margin-top:14px;">' + escapeHtml(tt('choose.running')) + '</p>'
|
||||
api.run(mode).then(function (result) {
|
||||
renderResult(result, mode)
|
||||
}).catch(function (err) {
|
||||
runState.innerHTML = '<p class="formMessage error" style="margin-top:14px;">' +
|
||||
escapeHtml(tt('choose.error', { message: (err && err.message) || String(err) })) + '</p>'
|
||||
trashBtn.disabled = false
|
||||
permBtn.disabled = false
|
||||
backBtn.disabled = false
|
||||
})
|
||||
}
|
||||
|
||||
trashBtn.addEventListener('click', function () { runMode('trash') })
|
||||
permBtn.addEventListener('click', function () { runMode('permanent') })
|
||||
}
|
||||
|
||||
// ── 3단계: 결과 ──────────────────────────────────
|
||||
function renderResult(result, mode) {
|
||||
var total = (result.removed ? result.removed.length : 0) + (result.profilesRemoved ? result.profilesRemoved.length : 0)
|
||||
var hasErr = result.errors && result.errors.length
|
||||
var cls = hasErr ? 'error' : 'done'
|
||||
var badge = hasErr ? tt('result.badgePartial') : tt('result.badgeOk')
|
||||
|
||||
var lines = ''
|
||||
if (result.removed && result.removed.length) {
|
||||
lines += '<p class="formMessage"><strong>' + escapeHtml(tt('result.removedTitle')) + '</strong></p><ul>'
|
||||
for (var i = 0; i < result.removed.length; i++) lines += '<li>' + escapeHtml(result.removed[i]) + '</li>'
|
||||
lines += '</ul>'
|
||||
}
|
||||
if (result.profilesRemoved && result.profilesRemoved.length) {
|
||||
lines += '<p class="formMessage"><strong>' + escapeHtml(tt('result.profilesTitle')) + '</strong></p><ul>'
|
||||
for (var j = 0; j < result.profilesRemoved.length; j++) lines += '<li>' + escapeHtml(result.profilesRemoved[j]) + '</li>'
|
||||
lines += '</ul>'
|
||||
}
|
||||
if (hasErr) {
|
||||
lines += '<p class="formMessage error"><strong>' + escapeHtml(tt('result.errorsTitle')) + '</strong></p><ul>'
|
||||
for (var k = 0; k < result.errors.length; k++) lines += '<li>' + escapeHtml(result.errors[k]) + '</li>'
|
||||
lines += '</ul>'
|
||||
}
|
||||
if (total === 0 && !hasErr) {
|
||||
lines += '<p class="formMessage">' + escapeHtml(tt('result.nothing')) + '</p>'
|
||||
}
|
||||
|
||||
pageHost.innerHTML =
|
||||
'<section class="page">' +
|
||||
' <div class="progressCard ' + cls + '" style="margin-top:6px;">' +
|
||||
' <div class="cardTop"><span class="statusBadge ' + (hasErr ? 'fail' : 'ok') + '">' + escapeHtml(badge) + '</span> ' +
|
||||
' <span class="label">' + escapeHtml(tt(mode === 'permanent' ? 'mode.permanent' : 'mode.trash')) + '</span></div>' +
|
||||
lines +
|
||||
' <p class="formMessage" style="margin-top:10px;"><small>' + escapeHtml(tt('result.note')) + '</small></p>' +
|
||||
' </div>' +
|
||||
' <div class="actionRow" style="margin-top:16px;">' +
|
||||
' <button class="primaryBtn" id="quitBtn">' + escapeHtml(tt('result.quitBtn')) + '</button>' +
|
||||
' </div>' +
|
||||
'</section>'
|
||||
|
||||
document.getElementById('quitBtn').addEventListener('click', function () { api.quit() })
|
||||
}
|
||||
|
||||
;(async function () {
|
||||
try { I18N = (await api.loadLocale()) || {} } catch (_) { I18N = {} }
|
||||
applyStaticI18n()
|
||||
renderConfirm()
|
||||
})()
|
||||
@@ -148,7 +148,7 @@ function renderStep1() {
|
||||
if (!state.selectedPackKey) return
|
||||
await installerApi.setSelectedPack(state.selectedPackKey)
|
||||
state.stepDone[1] = true
|
||||
renderAgreement()
|
||||
renderCloseNotice()
|
||||
})
|
||||
|
||||
;(async function () {
|
||||
@@ -162,6 +162,24 @@ function renderStep1() {
|
||||
})()
|
||||
}
|
||||
|
||||
// 퀴즈팩 선택 직후 노출하는 "마인크래프트/런처 종료" 강조 안내. 크게 표시.
|
||||
function renderCloseNotice() {
|
||||
setActiveStep(1)
|
||||
clearPage()
|
||||
var section = document.createElement('section')
|
||||
section.className = 'page'
|
||||
section.innerHTML =
|
||||
'<div style="margin:24px 0;padding:30px 24px;border:2px solid var(--danger);border-radius:14px;background:rgba(248,81,73,0.12);text-align:center;">' +
|
||||
' <div style="font-size:15px;font-weight:800;color:var(--danger);letter-spacing:2px;">' + escapeHtml(tt('closeNotice.badge')) + '</div>' +
|
||||
' <div style="font-size:30px;font-weight:900;line-height:1.45;margin-top:16px;">' + escapeHtml(tt('closeNotice.message')) + '</div>' +
|
||||
' <div style="font-size:14px;color:var(--text-muted);margin-top:18px;">' + escapeHtml(tt('closeNotice.sub')) + '</div>' +
|
||||
'</div>' +
|
||||
'<div class="actionRow"><button class="secondaryBtn" id="back">' + tt('common.back') + '</button><button class="primaryBtn" id="next">' + tt('common.next') + '</button></div>'
|
||||
pageHost.appendChild(section)
|
||||
section.querySelector('#back').addEventListener('click', renderStep1)
|
||||
section.querySelector('#next').addEventListener('click', renderAgreement)
|
||||
}
|
||||
|
||||
// 약관 동의 페이지: 음악퀴즈 선택 직후, 싱글/멀티 선택(step2) 진입 전에 노출.
|
||||
// v0.3.4~ : 어떤 약관을 표시할지는 사이트(/manifest/terms/<pack>/index.json) 가
|
||||
// 결정. 메인 인스톨러용으로 표시 토글된 항목만 받아 탭을 만든다. 목록이 비어 있는 (terms:[])
|
||||
@@ -214,76 +232,110 @@ function showAgreementError(message) {
|
||||
section.querySelector('#retry').addEventListener('click', renderAgreement)
|
||||
}
|
||||
|
||||
// 약관을 한 건씩 페이지로 보여준다. 각 약관마다 "해당 약관에 동의합니다" 체크가 있고,
|
||||
// 끝까지 스크롤해 읽어야 체크할 수 있으며, [다음] 을 누르면 다음 약관 페이지가 화면
|
||||
// 맨 위에서부터 나온다. 마지막 약관까지 동의하면 다음 단계(step2)로 진행한다.
|
||||
function renderAgreementWithKinds(KINDS) {
|
||||
var idx = 0
|
||||
var accepted = {} // kind -> true (뒤로 갔다 와도 동의 상태 유지)
|
||||
var cache = {} // kind -> 렌더된 HTML
|
||||
|
||||
var section = document.createElement('section')
|
||||
section.className = 'page'
|
||||
section.innerHTML =
|
||||
'<h2>' + tt('agreement.heading') + '</h2>' +
|
||||
'<p class="formMessage">' + tt('agreement.intro') + '</p>' +
|
||||
'<div class="tabBar" id="agTabs">' +
|
||||
KINDS.map(function (k, i) {
|
||||
return '<button type="button" class="tabBtn' + (i === 0 ? ' active' : '') + '" data-ag="' + escapeHtml(k.id) + '">' + escapeHtml(k.tab) + '</button>'
|
||||
}).join('') +
|
||||
'</div>' +
|
||||
'<div class="agreementBody" id="agBody">' + tt('agreement.loading') + '</div>' +
|
||||
'<label class="toggleRow" style="margin-top:12px;"><input type="checkbox" id="agAccept" /> ' +
|
||||
tt('agreement.agreeAll') + '</label>' +
|
||||
'<div class="formMessage" id="agMsg"></div>' +
|
||||
'<div class="actionRow"><button class="secondaryBtn" id="back">' + tt('common.back') + '</button><button class="primaryBtn" id="next" disabled>' + tt('common.next') + '</button></div>'
|
||||
pageHost.appendChild(section)
|
||||
|
||||
var body = section.querySelector('#agBody')
|
||||
var tabs = section.querySelectorAll('[data-ag]')
|
||||
var nextBtn = section.querySelector('#next')
|
||||
var accept = section.querySelector('#agAccept')
|
||||
var msg = section.querySelector('#agMsg')
|
||||
function renderCurrent() {
|
||||
var k = KINDS[idx]
|
||||
var isLast = idx === KINDS.length - 1
|
||||
section.innerHTML =
|
||||
'<h2>' + tt('agreement.heading') + '</h2>' +
|
||||
'<p class="formMessage">' + escapeHtml(tt('agreement.stepLabel', { current: idx + 1, total: KINDS.length, label: k.tab })) + '</p>' +
|
||||
'<div class="agreementBody" id="agBody" style="border-radius:10px;">' + tt('agreement.loading') + '</div>' +
|
||||
'<div class="formMessage" id="agHint">' + tt('agreement.readToBottom') + '</div>' +
|
||||
'<label class="toggleRow" style="margin-top:8px;"><input type="checkbox" id="agAccept" disabled /> ' +
|
||||
tt('agreement.agreeThis') + '</label>' +
|
||||
'<div class="formMessage" id="agMsg"></div>' +
|
||||
'<div class="actionRow"><button class="secondaryBtn" id="back">' + tt('common.back') + '</button><button class="primaryBtn" id="next" disabled>' + tt('common.next') + '</button></div>'
|
||||
|
||||
// 약관 본문은 한 번 받으면 캐시. 탭 전환 시 재요청하지 않는다.
|
||||
var cache = {}
|
||||
var body = section.querySelector('#agBody')
|
||||
var accept = section.querySelector('#agAccept')
|
||||
var nextBtn = section.querySelector('#next')
|
||||
var msg = section.querySelector('#agMsg')
|
||||
var hint = section.querySelector('#agHint')
|
||||
|
||||
function showKind(kind) {
|
||||
if (cache[kind]) {
|
||||
body.innerHTML = cache[kind]
|
||||
return
|
||||
// 새 약관 페이지는 화면 맨 위에서부터 보이도록 스크롤을 올린다.
|
||||
if (pageHost) pageHost.scrollTop = 0
|
||||
|
||||
function markReadable() {
|
||||
if (!accept.disabled) return
|
||||
accept.disabled = false
|
||||
hint.textContent = ''
|
||||
}
|
||||
body.textContent = tt('agreement.loading')
|
||||
installerApi.getTerm(kind).then(function (res) {
|
||||
if (!res.ok) {
|
||||
body.innerHTML = '<p class="formMessage error">' + tt('agreement.loadFailed', { message: res.message || '' }) + '</p>'
|
||||
function checkScrolled() {
|
||||
// 본문을 끝까지(하단 근처) 내렸으면 동의 체크를 허용한다.
|
||||
if (body.scrollHeight - body.scrollTop - body.clientHeight <= 6) markReadable()
|
||||
}
|
||||
body.addEventListener('scroll', checkScrolled)
|
||||
|
||||
accept.addEventListener('change', function () {
|
||||
accepted[k.id] = accept.checked
|
||||
nextBtn.disabled = !accept.checked
|
||||
if (accept.checked) { msg.textContent = ''; msg.classList.remove('error') }
|
||||
})
|
||||
|
||||
nextBtn.addEventListener('click', function () {
|
||||
if (!accept.checked) {
|
||||
msg.textContent = tt('agreement.agreeRequired')
|
||||
msg.classList.add('error')
|
||||
return
|
||||
}
|
||||
var html = renderTermsMarkdown(res.content || '')
|
||||
cache[kind] = html
|
||||
body.innerHTML = html
|
||||
}).catch(function (err) {
|
||||
body.innerHTML = '<p class="formMessage error">' + tt('agreement.loadFailed', { message: err.message }) + '</p>'
|
||||
if (isLast) renderStep2()
|
||||
else { idx++; renderCurrent() }
|
||||
})
|
||||
section.querySelector('#back').addEventListener('click', function () {
|
||||
if (idx === 0) renderStep1()
|
||||
else { idx--; renderCurrent() }
|
||||
})
|
||||
|
||||
function afterLoad() {
|
||||
body.scrollTop = 0
|
||||
// 이미 동의했던 약관으로 되돌아온 경우: 체크/다음 활성화 유지.
|
||||
if (accepted[k.id]) {
|
||||
accept.disabled = false
|
||||
accept.checked = true
|
||||
nextBtn.disabled = false
|
||||
hint.textContent = ''
|
||||
}
|
||||
// 레이아웃 확정 후: 스크롤이 필요 없을 만큼 짧은 약관이면 바로 동의 허용.
|
||||
setTimeout(function () {
|
||||
if (body.scrollHeight - body.clientHeight <= 6) markReadable()
|
||||
else checkScrolled()
|
||||
}, 0)
|
||||
}
|
||||
|
||||
if (cache[k.id]) {
|
||||
body.innerHTML = cache[k.id]
|
||||
afterLoad()
|
||||
} else {
|
||||
body.textContent = tt('agreement.loading')
|
||||
installerApi.getTerm(k.id).then(function (res) {
|
||||
if (!res.ok) {
|
||||
body.innerHTML = '<p class="formMessage error">' + tt('agreement.loadFailed', { message: res.message || '' }) + '</p>'
|
||||
markReadable()
|
||||
return
|
||||
}
|
||||
var html = renderTermsMarkdown(res.content || '')
|
||||
cache[k.id] = html
|
||||
body.innerHTML = html
|
||||
afterLoad()
|
||||
}).catch(function (err) {
|
||||
body.innerHTML = '<p class="formMessage error">' + tt('agreement.loadFailed', { message: err.message }) + '</p>'
|
||||
markReadable()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
tabs.forEach(function (b) {
|
||||
b.addEventListener('click', function () {
|
||||
tabs.forEach(function (x) { x.classList.remove('active') })
|
||||
b.classList.add('active')
|
||||
showKind(b.getAttribute('data-ag'))
|
||||
})
|
||||
})
|
||||
|
||||
accept.addEventListener('change', function () {
|
||||
nextBtn.disabled = !accept.checked
|
||||
if (accept.checked) msg.textContent = ''
|
||||
})
|
||||
|
||||
nextBtn.addEventListener('click', function () {
|
||||
if (!accept.checked) {
|
||||
msg.textContent = tt('agreement.agreeRequired')
|
||||
msg.classList.add('error')
|
||||
return
|
||||
}
|
||||
renderStep2()
|
||||
})
|
||||
section.querySelector('#back').addEventListener('click', renderStep1)
|
||||
|
||||
showKind(KINDS[0].id)
|
||||
renderCurrent()
|
||||
}
|
||||
|
||||
// 인스톨러용 미니 markdown 렌더러. 사이트 termsEditor 와 동일한 규칙을 처리한다.
|
||||
@@ -820,16 +872,20 @@ function renderSubStep35(host, back, done) {
|
||||
var result = await installerApi.checkPortForward(port)
|
||||
state.serverInstall.portStatus = result
|
||||
var address = formatServerAddress(result.externalIp, result.port)
|
||||
if (result.status === 'preForwarded') {
|
||||
resultMsg.innerHTML = tt('step3.sub35.preForwarded', { address: address })
|
||||
resultMsg.classList.add('success')
|
||||
} else if (result.status === 'upnpOk') {
|
||||
resultMsg.innerHTML = tt('step3.sub35.upnpOk', { address: address })
|
||||
resultMsg.classList.add('success')
|
||||
if (result.status === 'open') {
|
||||
// 열려 있으면 외부 접속 주소를 크게 표시.
|
||||
resultMsg.innerHTML =
|
||||
'<div style="margin-top:12px;padding:18px;border:1px solid var(--success);border-radius:10px;background:rgba(63,185,80,0.12);text-align:center;">' +
|
||||
'<div style="font-size:14px;color:var(--text-muted);">' + escapeHtml(tt('step3.sub35.openTitle')) + '</div>' +
|
||||
'<div style="font-size:30px;font-weight:800;margin-top:8px;user-select:all;word-break:break-all;">' + escapeHtml(address) + '</div>' +
|
||||
'</div>'
|
||||
} else {
|
||||
resultMsg.innerHTML = (result.message || tt('step3.sub35.manualHint')) +
|
||||
tt('step3.sub35.manualDetail', { address: address })
|
||||
resultMsg.classList.add('warn')
|
||||
// 안 열려 있으면 "직접 포트포워딩 해주세요" 를 크게 표시.
|
||||
resultMsg.innerHTML =
|
||||
'<div style="margin-top:12px;padding:18px;border:1px solid var(--danger);border-radius:10px;background:rgba(248,81,73,0.10);text-align:center;">' +
|
||||
'<div style="font-size:26px;font-weight:800;">' + escapeHtml(tt('step3.sub35.notOpenBig')) + '</div>' +
|
||||
'<div style="font-size:13px;color:var(--text-muted);margin-top:10px;">' + escapeHtml(tt('step3.sub35.notOpenHint', { address: address, port: result.port })) + '</div>' +
|
||||
'</div>'
|
||||
}
|
||||
nextBtn.disabled = false
|
||||
} catch (err) {
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
"cleanup": "이전 UPnP 매핑 정리 중…",
|
||||
"externalIpHttp": "외부 IP(HTTP): {{ip}}",
|
||||
"externalIpHttpFail": "외부 IP HTTP 조회 실패 → UPnP 게이트웨이로 폴백",
|
||||
"externalIpUpnp": "외부 IP(UPnP): {{ip}}",
|
||||
"externalIpFail": "외부 IP 확인 실패",
|
||||
"probeStart": "외부 포트 점검 시작…",
|
||||
"probeResult": "점검 결과: {{verdict}} ({{detail}})",
|
||||
"preForwarded": "이미 외부에서 접속 가능한 상태입니다.",
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
},
|
||||
"agreement": {
|
||||
"heading": "약관 동의",
|
||||
"intro": "리소스팩을 설치하기 전에 아래 약관을 모두 확인하고 동의해 주세요.",
|
||||
"intro": "리소스팩을 설치하기 전에 아래 약관을 한 건씩 끝까지 읽고 동의해 주세요.",
|
||||
"tabResourcepack": "리소스팩 약관",
|
||||
"tabInstaller": "리소스팩 설치기 약관",
|
||||
"loading": "약관을 불러오는 중...",
|
||||
@@ -41,6 +41,9 @@
|
||||
"listLoadFailed": "약관 표시에 실패하여 설치를 진행할 수 없습니다.\n사유: {{message}}\n네트워크 상태를 확인하고 다시 시도하거나, 처음 단계로 돌아가 주세요.",
|
||||
"retry": "다시 시도",
|
||||
"agreeAll": "위 모든 약관에 동의합니다.",
|
||||
"agreeThis": "해당 약관에 동의합니다.",
|
||||
"readToBottom": "약관을 끝까지 내려서 확인하면 동의할 수 있습니다.",
|
||||
"stepLabel": "약관 {{current}}/{{total}} — {{label}}",
|
||||
"agreeRequired": "약관에 동의해야 다음 단계로 진행할 수 있습니다.",
|
||||
"cancelling": "취소 중…"
|
||||
},
|
||||
|
||||
63
locales/installer-uninstall/ko-kr.json
Normal file
63
locales/installer-uninstall/ko-kr.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"app": {
|
||||
"title": "음악퀴즈 파일제거"
|
||||
},
|
||||
"logViewer": {
|
||||
"heading": "로그",
|
||||
"collapse": "접기",
|
||||
"expand": "펼치기"
|
||||
},
|
||||
"mode": {
|
||||
"trash": "휴지통으로 이동",
|
||||
"permanent": "컴퓨터에서 완전 삭제"
|
||||
},
|
||||
"confirm": {
|
||||
"heading": "음악퀴즈 파일제거",
|
||||
"question": "음악퀴즈 간편설치기로 설치한 내용들과, 음악퀴즈 관련된 내용을 전부 삭제하시겠습니까?",
|
||||
"detail": "음악퀴즈 간편설치기·리소스팩설치기가 만든 게임 폴더와 캐시, 마인크래프트 런처의 음악퀴즈 프로필을 정리합니다. 평소 쓰던 .minecraft 본체는 건드리지 않습니다.",
|
||||
"loadingPreview": "삭제 대상을 확인하는 중…",
|
||||
"previewTitle": "삭제 대상",
|
||||
"itemCustomDir": "음악퀴즈 전용 폴더: {{path}}",
|
||||
"itemCustomDirMissing": "음악퀴즈 전용 폴더가 없음(이미 삭제됨): {{path}}",
|
||||
"itemShortcut": "바탕화면의 'MusicQuiz Server' 바로가기",
|
||||
"itemProfiles": "마인크래프트 런처 프로필: {{names}}",
|
||||
"nothingFound": "삭제할 음악퀴즈 관련 항목을 찾지 못했습니다. 이미 정리된 상태일 수 있습니다.",
|
||||
"previewFail": "삭제 대상 확인 실패: {{message}}",
|
||||
"agreeBtn": "동의하고 계속",
|
||||
"cancelBtn": "취소(종료)"
|
||||
},
|
||||
"choose": {
|
||||
"heading": "삭제 방식 선택",
|
||||
"intro": "삭제 방식을 선택하세요.",
|
||||
"trashTitle": "휴지통으로 이동",
|
||||
"trashDesc": "휴지통으로 옮깁니다. 실수했을 때 되돌릴 수 있습니다.",
|
||||
"permTitle": "컴퓨터에서 완전 삭제",
|
||||
"permDesc": "휴지통을 거치지 않고 즉시 완전히 지웁니다. 되돌릴 수 없습니다.",
|
||||
"backBtn": "뒤로",
|
||||
"confirmTrash": "선택한 음악퀴즈 관련 항목을 휴지통으로 이동합니다. 계속하시겠습니까?",
|
||||
"confirmPermanent": "선택한 음악퀴즈 관련 항목을 컴퓨터에서 완전히 삭제합니다. 되돌릴 수 없습니다. 계속하시겠습니까?",
|
||||
"running": "삭제하는 중…",
|
||||
"error": "삭제 중 오류: {{message}}"
|
||||
},
|
||||
"result": {
|
||||
"badgeOk": "완료",
|
||||
"badgePartial": "일부 실패",
|
||||
"removedTitle": "삭제한 항목",
|
||||
"profilesTitle": "제거한 런처 프로필",
|
||||
"errorsTitle": "삭제하지 못한 항목",
|
||||
"nothing": "삭제할 항목이 없었습니다.",
|
||||
"note": "직접 지정한 위치에 서버를 설치했다면 그 폴더는 위치를 알 수 없어 자동 삭제되지 않습니다. 필요하면 직접 삭제하세요.",
|
||||
"quitBtn": "종료"
|
||||
},
|
||||
"log": {
|
||||
"start": "삭제 시작 ({{mode}})",
|
||||
"removedDir": "폴더 제거: {{path}}",
|
||||
"removedShortcut": "바로가기 제거: {{path}}",
|
||||
"removedProfile": "런처 프로필 제거: {{name}}",
|
||||
"removeFail": "제거 실패: {{path}} — {{message}}",
|
||||
"customDirMissing": "음악퀴즈 폴더가 이미 없음: {{path}}",
|
||||
"launcherParseFail": "launcher_profiles.json 을 읽지 못함: {{path}}",
|
||||
"launcherWriteFail": "launcher_profiles.json 갱신 실패: {{message}}",
|
||||
"done": "정리 완료 — 총 {{count}}개 항목 처리"
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,11 @@
|
||||
"heading": "시작하기 전에",
|
||||
"message": "마인크래프트 런처를 끄고 시작해주세요."
|
||||
},
|
||||
"closeNotice": {
|
||||
"badge": "⚠ 매우 중요",
|
||||
"message": "마인크래프트와 마인크래프트 런처를 종료한 뒤 진행해주세요",
|
||||
"sub": "실행 중이면 설치 설정이 제대로 적용되지 않을 수 있습니다."
|
||||
},
|
||||
"common": {
|
||||
"back": "이전",
|
||||
"next": "다음",
|
||||
@@ -36,7 +41,7 @@
|
||||
},
|
||||
"agreement": {
|
||||
"heading": "약관 동의",
|
||||
"intro": "설치 전에 아래 약관을 모두 확인하고 동의해 주세요.",
|
||||
"intro": "설치 전에 아래 약관을 한 건씩 끝까지 읽고 동의해 주세요.",
|
||||
"tabMap": "맵 약관",
|
||||
"tabMod": "모드 약관",
|
||||
"tabInstaller": "설치기 약관",
|
||||
@@ -45,6 +50,9 @@
|
||||
"listLoadFailed": "약관 표시에 실패하여 설치를 진행할 수 없습니다.\n사유: {{message}}\n네트워크 상태를 확인하고 다시 시도하거나, 처음 단계로 돌아가 주세요.",
|
||||
"retry": "다시 시도",
|
||||
"agreeAll": "위 모든 약관에 동의합니다.",
|
||||
"agreeThis": "해당 약관에 동의합니다.",
|
||||
"readToBottom": "약관을 끝까지 내려서 확인하면 동의할 수 있습니다.",
|
||||
"stepLabel": "약관 {{current}}/{{total}} — {{label}}",
|
||||
"agreeRequired": "약관에 동의해야 다음 단계로 진행할 수 있습니다."
|
||||
},
|
||||
"step1": {
|
||||
@@ -124,14 +132,13 @@
|
||||
},
|
||||
"sub35": {
|
||||
"heading": "포트포워딩",
|
||||
"description": "UPNP를 개방해 외부 접속을 허용합니다.",
|
||||
"description": "포트가 외부에서 열려 있는지 확인합니다. (설치기가 직접 열지는 않습니다)",
|
||||
"portLabel": "포트",
|
||||
"recheck": "재점검",
|
||||
"checking": "확인 중...",
|
||||
"preForwarded": "포트포워딩 성공! 친구는 <strong>{{address}}</strong> 주소로 서버에 접속할 수 있습니다. (이미 외부 개방되어 있음)",
|
||||
"upnpOk": "포트포워딩 성공! 친구는 <strong>{{address}}</strong> 주소로 서버에 접속할 수 있습니다. (UPnP로 자동 개방 완료)",
|
||||
"manualHint": "직접 포트포워딩을 해주세요.",
|
||||
"manualDetail": "<br><small>외부 주소: {{address}}</small>",
|
||||
"openTitle": "포트가 열려 있습니다! 친구 접속 주소",
|
||||
"notOpenBig": "직접 포트포워딩 해주세요.",
|
||||
"notOpenHint": "공유기에서 외부 TCP {{port}} 를 이 PC 로 포워딩하세요. (외부 주소: {{address}})",
|
||||
"checkFailed": "점검 실패: {{message}}",
|
||||
"ipUnknown": "확인 불가"
|
||||
}
|
||||
@@ -187,7 +194,6 @@
|
||||
"fabricLoaderRequired": "Fabric 로더 버전이 음악퀴즈에 지정되지 않았습니다. 관리 사이트에서 platform.loaderVersion 을 설정해 주세요.",
|
||||
"fabricInstallerListEmpty": "Fabric installer 목록을 받지 못했습니다.",
|
||||
"portAllocFail": "포트를 할당할 수 없습니다.",
|
||||
"upnpTimeout": "UPnP 응답 없음(타임아웃 15s). 라우터의 UPnP가 꺼져 있거나 SSDP 패킷이 차단됐을 수 있습니다.",
|
||||
"parseResponseFailed": "응답 파싱 실패: {{snippet}}"
|
||||
},
|
||||
"log": {
|
||||
@@ -218,15 +224,10 @@
|
||||
"skipResourcepack": "resourcepackPath가 비어 있어 리소스팩 다운로드를 건너뜁니다.",
|
||||
"resourcepackDownload": "리소스팩 다운로드: {{url}}",
|
||||
"serverInstallPath": "서버 설치 경로: {{path}}",
|
||||
"runBatMissing": "run.bat 이 없어 UPnP 자동 등록 스크립트 주입을 건너뜁니다.",
|
||||
"runBatAlreadyInjected": "run.bat 에 이미 UPnP 자동 등록 스크립트가 들어 있어 건너뜁니다.",
|
||||
"runBatNoJava": "run.bat 에서 java 호출 라인을 찾지 못해 UPnP 자동 등록 주입을 건너뜁니다.",
|
||||
"runBatInjected": "run.bat 에 서버 기동/종료 시 UPnP 자동 등록·해제 스크립트를 추가했습니다.",
|
||||
"mojangEulaFetchFail": "Minecraft EULA 페이지 조회 실패: {{message}}",
|
||||
"eulaAccepted": "EULA 동의 저장 완료.",
|
||||
"configEditorOpen": "서버 설정 편집기 실행: {{url}}",
|
||||
"portCheckStart": "포트포워딩 점검 시작: 포트 {{port}}",
|
||||
"upnpCleanup": "이전 실행의 UPnP 매핑이 남아 있으면 제거합니다(중복 방지)...",
|
||||
"externalIpHttp": "외부 IP 확인(HTTP): {{ip}}",
|
||||
"externalIpHttpFail": "외부 IP 확인 실패(HTTP). UPnP 게이트웨이를 통한 조회 시도...",
|
||||
"externalIpUpnp": "외부 IP 확인(UPnP): {{ip}}",
|
||||
@@ -238,15 +239,6 @@
|
||||
"probeVerdictUnknown": "확인 불가",
|
||||
"probePreForwarded": "외부에서 {{addr}}:{{port}} 접근 확인됨. 사용자 규칙으로 포워딩 됨.",
|
||||
"ipUnknown": "(IP 미상)",
|
||||
"upnpTryOpen": "UPnP로 포트 {{port}} 자동 개방 시도(TCP)...",
|
||||
"upnpReqOk": "UPnP portMapping 요청 성공. 외부 접근을 재확인합니다.",
|
||||
"upnpTryFail": "UPnP 시도 실패: {{message}}",
|
||||
"upnpFailDetail": "UPnP 실패: {{message}}. 라우터에서 UPnP가 꺼져 있을 수 있습니다. 직접 포트포워딩을 해주세요.",
|
||||
"upnpRecheck": "UPnP 적용 후 재점검 {{attempt}}/3...",
|
||||
"upnpDone": "UPnP로 포트 {{port}} 자동 개방 완료. 테스트 매핑을 제거합니다(실제 개방은 run.bat 이 서버 기동 시 자동으로 처리).",
|
||||
"upnpCleanupTest": "테스트용 UPnP 매핑을 정리합니다.",
|
||||
"upnpFailReason1": "UPnP 매핑은 등록됐지만 외부 포트체크 서비스에서 연결이 닿지 않았습니다. ISP 차단, 이중 NAT, 또는 방화벽 설정을 확인하세요.",
|
||||
"upnpFailReason2": "외부 포트체크 결과를 받지 못했습니다({{detail}}). UPnP 매핑은 등록됐을 수 있습니다.",
|
||||
"upnpClientFail": "UPnP 클라이언트 생성 실패: {{message}}",
|
||||
"upnpExternalTimeout": "UPnP externalIp 조회 타임아웃(8s).",
|
||||
"upnpExternalErr": "UPnP externalIp 오류: {{message}}",
|
||||
@@ -257,10 +249,6 @@
|
||||
"detailIfconfig": "ifconfig.co reachable={{reachable}} ip={{ip}}",
|
||||
"detailIfconfigFail": "ifconfig.co 실패={{error}}",
|
||||
"detailNone": "결과 없음",
|
||||
"upnpClientFailRemove": "UPnP 클라이언트 생성 실패(매핑 제거 단계): {{message}}",
|
||||
"upnpRemoveTimeout": "UPnP 매핑 제거 응답 없음(타임아웃 8s). 라우터에 우리가 만든 규칙이 없을 수 있습니다.",
|
||||
"upnpRemoveAttempt": "UPnP 매핑 제거 시도 결과: {{message}} (없으면 정상)",
|
||||
"upnpRemoveDone": "UPnP 매핑 제거 완료(포트 {{port}}).",
|
||||
"platformDownload": "플랫폼({{type}}) 다운로드: {{url}}",
|
||||
"platformSaved": "플랫폼 설치파일 저장: {{path}} (사용자가 직접 실행하거나 마인크래프트 런처에서 인식할 수 있습니다.)",
|
||||
"platformSkipped": "플랫폼 설치 건너뜀. 바닐라로 진행합니다.",
|
||||
@@ -297,7 +285,8 @@
|
||||
"launcherAppsFolderFail": "AppsFolder 실행 실패: {{message}}",
|
||||
"launcherUrlSchemeFallback": "마지막 시도: minecraft:// URL 스킴 (런처가 없으면 MS Store 가 열릴 수 있음).",
|
||||
"launcherUrlSchemeFail": "URL 스킴 실행 실패: {{message}}.",
|
||||
"launcherAllFail": "Minecraft Launcher 실행 시도가 모두 실패했습니다. minecraft.net 또는 Microsoft Store 에서 \"Minecraft Launcher\" 를 설치한 뒤 다시 시도해 주세요."
|
||||
"launcherAllFail": "Minecraft Launcher 실행 시도가 모두 실패했습니다. minecraft.net 또는 Microsoft Store 에서 \"Minecraft Launcher\" 를 설치한 뒤 다시 시도해 주세요.",
|
||||
"internalError": "내부 오류(무시하고 계속): {{message}}"
|
||||
},
|
||||
"candidates": {
|
||||
"winProgramFiles86": "Win32 설치(Program Files (x86))",
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
"title": "관리자 로그인",
|
||||
"password": "비밀번호",
|
||||
"submit": "로그인",
|
||||
"wrongPassword": "비밀번호가 올바르지 않습니다."
|
||||
"wrongPassword": "비밀번호가 올바르지 않습니다.",
|
||||
"tooManyAttempts": "로그인 시도가 너무 많습니다. 약 {{minutes}}분 후 다시 시도해 주세요."
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "음악퀴즈 목록",
|
||||
@@ -229,6 +230,7 @@
|
||||
"ytdlpInstallFailed": "yt-dlp 자동 설치에 실패했습니다: {{message}}",
|
||||
"ytdlpVideoFailed": "yt-dlp 영상 조회 실패 (code={{code}}): {{detail}}",
|
||||
"ytdlpPlaylistFailed": "yt-dlp 플레이리스트 조회 실패 (code={{code}}): {{detail}}",
|
||||
"tooManyRedirects": "redirect 가 너무 많습니다."
|
||||
"tooManyRedirects": "redirect 가 너무 많습니다.",
|
||||
"invalidUrl": "올바르지 않은 URL 입니다. http/https 주소만 허용됩니다."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minecraft-music-quiz-installer",
|
||||
"version": "0.3.18",
|
||||
"version": "0.4.1",
|
||||
"description": "마인크래프트 음악퀴즈 간편설치기 + 관리 사이트",
|
||||
"main": "dist/installer/main.js",
|
||||
"scripts": {
|
||||
@@ -10,11 +10,15 @@
|
||||
"installer": "tsc -p tsconfig.installer.json && electron .",
|
||||
"installer:rp": "tsc -p tsconfig.installer-rp.json && electron dist/installer-rp/main.js",
|
||||
"installer:pf": "tsc -p tsconfig.installer-pf.json && electron dist/installer-pf/main.js",
|
||||
"installer:uninstall": "tsc -p tsconfig.installer-uninstall.json && electron dist/installer-uninstall/main.js",
|
||||
"preinstall:sharp-win32": "npm install --no-save --force @img/sharp-win32-x64@0.34.5",
|
||||
"build:launcher-icon": "node scripts/build-launcher-icon.cjs",
|
||||
"dist:win": "npm run preinstall:sharp-win32 && npm run build:launcher-icon && tsc -p tsconfig.installer.json && electron-builder --win --config electron-builder.yml",
|
||||
"dist:win:rp": "npm run preinstall:sharp-win32 && tsc -p tsconfig.installer-rp.json && electron-builder --win --config electron-builder-rp.yml",
|
||||
"dist:win:pf": "tsc -p tsconfig.installer-pf.json && electron-builder --win --config electron-builder-pf.yml"
|
||||
"dist:win:pf": "tsc -p tsconfig.installer-pf.json && electron-builder --win --config electron-builder-pf.yml",
|
||||
"dist:win:dev": "npm run preinstall:sharp-win32 && npm run build:launcher-icon && tsc -p tsconfig.installer.json && electron-builder --win --config electron-builder-dev.yml",
|
||||
"dist:win:rp:dev": "npm run preinstall:sharp-win32 && tsc -p tsconfig.installer-rp.json && electron-builder --win --config electron-builder-rp-dev.yml",
|
||||
"dist:win:uninstall": "tsc -p tsconfig.installer-uninstall.json && electron-builder --win --config electron-builder-uninstall.yml"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/archiver": "^7.0.0",
|
||||
|
||||
@@ -16,6 +16,13 @@ const localeDict = i18n.dict
|
||||
|
||||
let mainWindow: BrowserWindow | null = null
|
||||
|
||||
// 이 도구가 UPnP 로 직접 열어둔 포트. 앱이 살아 있는 동안 매핑을 유지하고,
|
||||
// 창을 닫거나 종료할 때 이 포트의 매핑을 제거한다(사용자가 라우터에 직접 만든
|
||||
// 영구 규칙으로 이미 열려 있던 preForwarded 포트는 우리 것이 아니므로 추적하지 않음).
|
||||
let activePort: number | null = null
|
||||
// before-quit 재진입 가드. 매핑 정리를 마친 뒤에만 실제 종료로 넘어가게 한다.
|
||||
let cleanupDone = false
|
||||
|
||||
function createMainWindow(): void {
|
||||
const iconPath = path.join(__dirname, '..', '..', 'build', process.platform === 'win32' ? 'icon.ico' : 'icon.png')
|
||||
mainWindow = new BrowserWindow({
|
||||
@@ -355,6 +362,13 @@ ipcMain.handle('pf:open', async (_event, portInput: number): Promise<PortForward
|
||||
const localIp = detectLocalIpv4()
|
||||
if (localIp) sendLog(t('log.localIp', { ip: localIp }))
|
||||
|
||||
// 다른 포트를 이미 우리가 열어둔 상태에서 새 포트를 열면, 이전 포트 매핑을 먼저 닫아
|
||||
// 매핑이 새는 것을 막는다.
|
||||
if (activePort !== null && activePort !== port) {
|
||||
await removeUpnpMapping(activePort)
|
||||
activePort = null
|
||||
}
|
||||
|
||||
// 이전에 남은 매핑을 먼저 제거해 "사용자 라우터 규칙으로 이미 열린 상태" 와 구별.
|
||||
sendLog(t('log.cleanup'))
|
||||
await removeUpnpMapping(port)
|
||||
@@ -387,6 +401,8 @@ ipcMain.handle('pf:open', async (_event, portInput: number): Promise<PortForward
|
||||
sendLog(t('log.upnpTry', { port }))
|
||||
try {
|
||||
await openPortViaUpnp(port)
|
||||
// 우리가 연 포트로 기록 → 앱 종료/창 닫힘 시 자동으로 매핑 제거.
|
||||
activePort = port
|
||||
sendLog(t('log.upnpReqOk'))
|
||||
} catch (error) {
|
||||
const msg = (error as Error).message
|
||||
@@ -415,6 +431,7 @@ ipcMain.handle('pf:close', async (_event, portInput: number): Promise<void> => {
|
||||
const port = Number.isFinite(portInput) && portInput > 0 && portInput < 65536 ? Math.floor(portInput) : 25565
|
||||
sendLog(t('log.closeTry', { port }))
|
||||
await removeUpnpMapping(port)
|
||||
if (activePort === port) activePort = null
|
||||
})
|
||||
|
||||
ipcMain.handle('pf:quit', async () => {
|
||||
@@ -432,6 +449,20 @@ app.whenReady().then(() => {
|
||||
})
|
||||
})
|
||||
|
||||
// 창을 닫거나 종료할 때, 이 도구가 열어둔 UPnP 매핑을 제거한 뒤 실제 종료로 넘어간다.
|
||||
// removeUpnpMapping 은 비동기라 before-quit 을 한 번 막고(cleanup) 끝나면 다시 quit 한다.
|
||||
app.on('before-quit', (event) => {
|
||||
if (cleanupDone || activePort === null) return
|
||||
event.preventDefault()
|
||||
const port = activePort
|
||||
activePort = null
|
||||
sendLog(t('log.closeTry', { port }))
|
||||
void removeUpnpMapping(port).finally(() => {
|
||||
cleanupDone = true
|
||||
app.quit()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit()
|
||||
})
|
||||
|
||||
@@ -9,9 +9,10 @@ import { URL } from 'node:url'
|
||||
import type { ChildProcess } from 'node:child_process'
|
||||
import type { Manifest, PackDefinition, PackList } from '../shared/types.js'
|
||||
import { normalizePackDefinition } from '../shared/store.js'
|
||||
import { getAppDataDir, getMcCustomDir } from '../shared/paths.js'
|
||||
import { getAppDataDir, getMcCustomDir, withCustomDirName } from '../shared/paths.js'
|
||||
import { loadEnv, getManifestUrl } from '../shared/env.js'
|
||||
import { loadComponentI18n } from '../shared/i18n.js'
|
||||
import { resolveAudience, isPackVisibleForAudience, type Audience } from '../shared/audience.js'
|
||||
import type { RpFetchedPack } from './types.js'
|
||||
import { ensureYtDlpExe } from './ytdlp.js'
|
||||
import { ensureFfmpegExe } from './ffmpeg.js'
|
||||
@@ -112,6 +113,16 @@ const state: RpInstallerState = {
|
||||
|
||||
let mainWindow: BrowserWindow | null = null
|
||||
|
||||
// 이 빌드의 대상(일반/개발자용). package.json 의 musicQuizAudience 로 결정.
|
||||
function getAudience(): Audience {
|
||||
try {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(app.getAppPath(), 'package.json'), 'utf8'))
|
||||
return resolveAudience(pkg.musicQuizAudience)
|
||||
} catch {
|
||||
return resolveAudience(undefined)
|
||||
}
|
||||
}
|
||||
|
||||
function deriveBaseUrl(manifestUrl: string): string {
|
||||
try {
|
||||
const parsed = new URL(manifestUrl)
|
||||
@@ -202,9 +213,12 @@ ipcMain.handle('rp:packs:load', async (_event, manifestUrlInput?: string): Promi
|
||||
}
|
||||
sendLog(t('log.manifestDownload', { url: state.manifestUrl }))
|
||||
const manifest = await fetchJson<Manifest>(state.manifestUrl)
|
||||
const audience = getAudience()
|
||||
const results: RpFetchedPack[] = []
|
||||
for (const entry of manifest.packs ?? []) {
|
||||
if (typeof entry?.file !== 'string') continue
|
||||
// 대상(audience)에 맞지 않는 pack 은 건너뛴다(일반=public, 개발자용=non-public).
|
||||
if (!isPackVisibleForAudience(entry.public, audience)) continue
|
||||
const listUrl = `${state.baseUrl}/file/list/${encodeURIComponent(entry.file)}.json`
|
||||
const packUrl = `${state.baseUrl}/manifest/${encodeURIComponent(entry.file)}.json`
|
||||
try {
|
||||
@@ -259,7 +273,25 @@ ipcMain.handle('rp:packs:select', async (_event, packKey: string) => {
|
||||
sendLog(t('log.selectedPack', { key: packKey }))
|
||||
})
|
||||
|
||||
ipcMain.handle('rp:i18n:dict', () => localeDict)
|
||||
// 개발자용 빌드(musicQuizAudience=developer)면 렌더러에 넘기는 사전의 제목 앞에
|
||||
// "(개발자용) " 을 붙여, 창 제목/헤더에 개발자용임을 표시한다.
|
||||
function dictForRenderer(): Record<string, unknown> {
|
||||
// 커스텀 폴더명을 UI 문구에 반영.
|
||||
const base = withCustomDirName(localeDict)
|
||||
if (getAudience() !== 'developer') return base
|
||||
const prefix = '(개발자용) '
|
||||
const appBlock = (base.app ?? {}) as Record<string, unknown>
|
||||
const title = appBlock.title
|
||||
return {
|
||||
...base,
|
||||
app: {
|
||||
...appBlock,
|
||||
title: typeof title === 'string' && !title.startsWith(prefix) ? prefix + title : title
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle('rp:i18n:dict', () => dictForRenderer())
|
||||
|
||||
// ── IPC: 약관 다운로드 ──────────────────────────────
|
||||
// v0.3.4~ : 사이트에서 임의 kind 가 만들어질 수 있으니 5종 화이트리스트 대신
|
||||
|
||||
224
src/installer-uninstall/main.ts
Normal file
224
src/installer-uninstall/main.ts
Normal file
@@ -0,0 +1,224 @@
|
||||
import { app, BrowserWindow, ipcMain, shell } from 'electron'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
import fsp from 'node:fs/promises'
|
||||
import { loadEnv } from '../shared/env.js'
|
||||
import { getAppDataDir, getMcCustomDir } from '../shared/paths.js'
|
||||
import { loadComponentI18n } from '../shared/i18n.js'
|
||||
|
||||
// 음악퀴즈 파일제거 도구. 음악퀴즈 간편설치기 / 리소스팩설치기가 만든 데이터를
|
||||
// 한 번에 정리한다. (설치기 exe 자체는 사용자가 임의 위치에 둔 포터블이라
|
||||
// 위치를 알 수 없어 삭제 대상에서 제외)
|
||||
loadEnv()
|
||||
|
||||
const i18n = loadComponentI18n('installer-uninstall')
|
||||
const t = i18n.t
|
||||
const localeDict = i18n.dict
|
||||
|
||||
let mainWindow: BrowserWindow | null = null
|
||||
|
||||
function createMainWindow(): void {
|
||||
const iconPath = path.join(__dirname, '..', '..', 'build', process.platform === 'win32' ? 'icon.ico' : 'icon.png')
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 720,
|
||||
height: 620,
|
||||
icon: iconPath,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
mainWindow.removeMenu()
|
||||
void mainWindow.loadFile(path.join(__dirname, '..', '..', 'installer-uninstall', 'index.html'))
|
||||
}
|
||||
|
||||
function sendLog(line: string): void {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) return
|
||||
const stamped = `[${new Date().toLocaleTimeString('ko-KR', { hour12: false })}] ${line}`
|
||||
mainWindow.webContents.send('log', stamped)
|
||||
}
|
||||
|
||||
/** 마인크래프트 런처 프로필 파일 경로. */
|
||||
function launcherProfilesPath(): string {
|
||||
return path.join(getAppDataDir(), '.minecraft', 'launcher_profiles.json')
|
||||
}
|
||||
|
||||
/** 데스크톱에 설치기가 만든 서버 실행 바로가기 경로. */
|
||||
function serverShortcutPath(): string {
|
||||
return path.join(app.getPath('desktop'), 'MusicQuiz Server.lnk')
|
||||
}
|
||||
|
||||
/** 기본 폴더 이름(.mc_custom) 경로. MC_CUSTOM_DIR 을 바꿔 빌드해도, 예전 기본 폴더가 남아 있을 수 있으므로 함께 지운다. */
|
||||
function defaultCustomDir(): string {
|
||||
return path.join(getAppDataDir(), '.mc_custom')
|
||||
}
|
||||
|
||||
/** 삭제 대상 커스텀 폴더 후보(현재 설정값 + 기본 .mc_custom)를 대소문자 무시로 중복 제거. */
|
||||
function targetCustomDirs(): string[] {
|
||||
const seen = new Set<string>()
|
||||
const out: string[] = []
|
||||
for (const dir of [getMcCustomDir(), defaultCustomDir()]) {
|
||||
const key = path.resolve(dir).toLowerCase()
|
||||
if (!seen.has(key)) {
|
||||
seen.add(key)
|
||||
out.push(dir)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** 두 경로가 같은 폴더거나, a 가 b 하위인지(대소문자 무시 — Windows 파일계). */
|
||||
function isSameOrInside(child: string, parent: string): boolean {
|
||||
const c = path.resolve(child).replace(/[\\/]+$/, '').toLowerCase()
|
||||
const p = path.resolve(parent).replace(/[\\/]+$/, '').toLowerCase()
|
||||
return c === p || c.startsWith(p + path.sep.toLowerCase()) || c.startsWith(p + '/')
|
||||
}
|
||||
|
||||
interface UninstallPreview {
|
||||
existingDirs: string[]
|
||||
allTargetDirs: string[]
|
||||
shortcutExists: boolean
|
||||
launcherProfiles: string[]
|
||||
}
|
||||
|
||||
/** 삭제 전 미리보기: 실제로 존재하는 대상만 추려 렌더러에 보여준다. */
|
||||
ipcMain.handle('uninstall:preview', async (): Promise<UninstallPreview> => {
|
||||
const allTargetDirs = targetCustomDirs()
|
||||
const existingDirs = allTargetDirs.filter((d) => fs.existsSync(d))
|
||||
const shortcutExists = fs.existsSync(serverShortcutPath())
|
||||
const launcherProfiles = findMusicQuizProfiles(allTargetDirs)
|
||||
return { existingDirs, allTargetDirs, shortcutExists, launcherProfiles }
|
||||
})
|
||||
|
||||
/** launcher_profiles.json 에서 gameDir 가 커스텀 폴더(또는 그 하위)인 프로필 이름 목록. */
|
||||
function findMusicQuizProfiles(customDirs: string[]): string[] {
|
||||
const file = launcherProfilesPath()
|
||||
if (!fs.existsSync(file)) return []
|
||||
try {
|
||||
const json = JSON.parse(fs.readFileSync(file, 'utf8')) as {
|
||||
profiles?: Record<string, { name?: string; gameDir?: string }>
|
||||
}
|
||||
const profiles = json.profiles ?? {}
|
||||
const names: string[] = []
|
||||
for (const [key, prof] of Object.entries(profiles)) {
|
||||
const gameDir = typeof prof?.gameDir === 'string' ? prof.gameDir : ''
|
||||
if (gameDir && customDirs.some((d) => isSameOrInside(gameDir, d))) {
|
||||
names.push(typeof prof?.name === 'string' && prof.name ? prof.name : key)
|
||||
}
|
||||
}
|
||||
return names
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
interface UninstallResult {
|
||||
removed: string[]
|
||||
profilesRemoved: string[]
|
||||
errors: string[]
|
||||
}
|
||||
|
||||
/** 하나의 파일/폴더를 mode 에 따라 휴지통 이동 또는 완전 삭제. */
|
||||
async function removeOne(target: string, mode: 'trash' | 'permanent'): Promise<void> {
|
||||
if (mode === 'trash') {
|
||||
await shell.trashItem(target)
|
||||
} else {
|
||||
await fsp.rm(target, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
|
||||
/** launcher_profiles.json 에서 음악퀴즈 프로필만 제거하고 나머지는 보존. */
|
||||
async function cleanLauncherProfiles(customDirs: string[]): Promise<string[]> {
|
||||
const file = launcherProfilesPath()
|
||||
if (!fs.existsSync(file)) return []
|
||||
let json: { profiles?: Record<string, { name?: string; gameDir?: string }> }
|
||||
try {
|
||||
json = JSON.parse(await fsp.readFile(file, 'utf8'))
|
||||
} catch {
|
||||
sendLog(t('log.launcherParseFail', { path: file }))
|
||||
return []
|
||||
}
|
||||
const profiles = json.profiles ?? {}
|
||||
const removed: string[] = []
|
||||
for (const [key, prof] of Object.entries(profiles)) {
|
||||
const gameDir = typeof prof?.gameDir === 'string' ? prof.gameDir : ''
|
||||
if (gameDir && customDirs.some((d) => isSameOrInside(gameDir, d))) {
|
||||
removed.push(typeof prof?.name === 'string' && prof.name ? prof.name : key)
|
||||
delete profiles[key]
|
||||
}
|
||||
}
|
||||
if (removed.length > 0) {
|
||||
json.profiles = profiles
|
||||
await fsp.writeFile(file, `${JSON.stringify(json, null, 2)}\n`, 'utf8')
|
||||
}
|
||||
return removed
|
||||
}
|
||||
|
||||
ipcMain.handle('uninstall:run', async (_event, modeInput: unknown): Promise<UninstallResult> => {
|
||||
const mode: 'trash' | 'permanent' = modeInput === 'permanent' ? 'permanent' : 'trash'
|
||||
const customDirs = targetCustomDirs()
|
||||
const removed: string[] = []
|
||||
const errors: string[] = []
|
||||
|
||||
sendLog(t('log.start', { mode: t(mode === 'trash' ? 'mode.trash' : 'mode.permanent') }))
|
||||
|
||||
// 1) 커스텀 게임/캐시 폴더 통째로(현재 설정값 + 기본 .mc_custom).
|
||||
for (const customDir of customDirs) {
|
||||
if (fs.existsSync(customDir)) {
|
||||
try {
|
||||
await removeOne(customDir, mode)
|
||||
removed.push(customDir)
|
||||
sendLog(t('log.removedDir', { path: customDir }))
|
||||
} catch (err) {
|
||||
const msg = (err as Error).message
|
||||
errors.push(`${customDir}: ${msg}`)
|
||||
sendLog(t('log.removeFail', { path: customDir, message: msg }))
|
||||
}
|
||||
} else {
|
||||
sendLog(t('log.customDirMissing', { path: customDir }))
|
||||
}
|
||||
}
|
||||
|
||||
// 2) 데스크톱 서버 실행 바로가기.
|
||||
const shortcut = serverShortcutPath()
|
||||
if (fs.existsSync(shortcut)) {
|
||||
try {
|
||||
await removeOne(shortcut, mode)
|
||||
removed.push(shortcut)
|
||||
sendLog(t('log.removedShortcut', { path: shortcut }))
|
||||
} catch (err) {
|
||||
const msg = (err as Error).message
|
||||
errors.push(`${shortcut}: ${msg}`)
|
||||
sendLog(t('log.removeFail', { path: shortcut, message: msg }))
|
||||
}
|
||||
}
|
||||
|
||||
// 3) 마인크래프트 런처 프로필에서 음악퀴즈 설정 제거.
|
||||
let profilesRemoved: string[] = []
|
||||
try {
|
||||
profilesRemoved = await cleanLauncherProfiles(customDirs)
|
||||
for (const name of profilesRemoved) sendLog(t('log.removedProfile', { name }))
|
||||
} catch (err) {
|
||||
const msg = (err as Error).message
|
||||
errors.push(`launcher_profiles.json: ${msg}`)
|
||||
sendLog(t('log.launcherWriteFail', { message: msg }))
|
||||
}
|
||||
|
||||
sendLog(t('log.done', { count: removed.length + profilesRemoved.length }))
|
||||
return { removed, profilesRemoved, errors }
|
||||
})
|
||||
|
||||
ipcMain.handle('uninstall:i18n:dict', () => localeDict)
|
||||
ipcMain.handle('uninstall:quit', () => app.quit())
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createMainWindow()
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createMainWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit()
|
||||
})
|
||||
43
src/installer-uninstall/preload.ts
Normal file
43
src/installer-uninstall/preload.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { contextBridge, ipcRenderer } from 'electron'
|
||||
|
||||
interface UninstallPreview {
|
||||
customDir: string
|
||||
customDirExists: boolean
|
||||
shortcutExists: boolean
|
||||
launcherProfiles: string[]
|
||||
}
|
||||
|
||||
interface UninstallResult {
|
||||
removed: string[]
|
||||
profilesRemoved: string[]
|
||||
errors: string[]
|
||||
}
|
||||
|
||||
const api = {
|
||||
/** i18n 사전을 렌더러에 전달. */
|
||||
loadLocale: (): Promise<Record<string, unknown>> => ipcRenderer.invoke('uninstall:i18n:dict'),
|
||||
|
||||
/** 삭제 전, 실제로 존재하는 대상 미리보기. */
|
||||
preview: (): Promise<UninstallPreview> => ipcRenderer.invoke('uninstall:preview'),
|
||||
|
||||
/** 삭제 실행. mode: 'trash'(휴지통) | 'permanent'(완전 삭제). */
|
||||
run: (mode: 'trash' | 'permanent'): Promise<UninstallResult> => ipcRenderer.invoke('uninstall:run', mode),
|
||||
|
||||
/** 프로그램 종료. */
|
||||
quit: (): Promise<void> => ipcRenderer.invoke('uninstall:quit'),
|
||||
|
||||
/** 로그 스트림 구독. */
|
||||
onLog: (handler: (line: string) => void): (() => void) => {
|
||||
const listener = (_event: unknown, line: string) => handler(line)
|
||||
ipcRenderer.on('log', listener)
|
||||
return () => ipcRenderer.removeListener('log', listener)
|
||||
}
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('uninstaller', api)
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
uninstaller: typeof api
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,24 @@ import type {
|
||||
} from './types.js'
|
||||
import type { Manifest, PackDefinition } from '../shared/types.js'
|
||||
import { normalizePackDefinition } from '../shared/store.js'
|
||||
import { getMcCustomDirName, withCustomDirName } from '../shared/paths.js'
|
||||
import { loadEnv, getManifestUrl } from '../shared/env.js'
|
||||
import { loadComponentI18n } from '../shared/i18n.js'
|
||||
import { resolveAudience, isPackVisibleForAudience, type Audience } from '../shared/audience.js'
|
||||
import { LAUNCHER_PROFILE_ICON } from './launcherIcon.js'
|
||||
|
||||
loadEnv()
|
||||
|
||||
// 이 빌드의 대상(일반/개발자용). package.json 의 musicQuizAudience 로 결정.
|
||||
function getAudience(): Audience {
|
||||
try {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(app.getAppPath(), 'package.json'), 'utf8'))
|
||||
return resolveAudience(pkg.musicQuizAudience)
|
||||
} catch {
|
||||
return resolveAudience(undefined)
|
||||
}
|
||||
}
|
||||
|
||||
const i18n = loadComponentI18n('installer')
|
||||
const t = i18n.t
|
||||
export const localeDict = i18n.dict
|
||||
@@ -87,6 +99,16 @@ function sendLog(line: string): void {
|
||||
mainWindow.webContents.send('log', stamped)
|
||||
}
|
||||
|
||||
// nat-upnp(detectExternalIpUpnp) 등이 콜백 밖에서 비동기 소켓 오류를 내면 처리되지
|
||||
// 않아 Electron 메인이 종료되며 창이 갑자기 닫힐 수 있다. 전역 가드로 잡아 로그만
|
||||
// 남기고 앱은 계속 살려 둔다(포트포워딩 전용 도구 v0.3.18 과 동일한 대비책).
|
||||
process.on('uncaughtException', (err) => {
|
||||
try { sendLog(t('log.internalError', { message: (err as Error)?.message || String(err) })) } catch {}
|
||||
})
|
||||
process.on('unhandledRejection', (reason) => {
|
||||
try { sendLog(t('log.internalError', { message: reason instanceof Error ? reason.message : String(reason) })) } catch {}
|
||||
})
|
||||
|
||||
function fetchBuffer(url: string): Promise<Buffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const target = new URL(url)
|
||||
@@ -136,9 +158,12 @@ ipcMain.handle('packs:load', async (_event, manifestUrlInput?: string): Promise<
|
||||
}
|
||||
sendLog(t('log.manifestDownload', { url: state.manifestUrl }))
|
||||
const manifest = await fetchJson<Manifest>(state.manifestUrl)
|
||||
const audience = getAudience()
|
||||
const results: FetchedPack[] = []
|
||||
for (const entry of manifest.packs ?? []) {
|
||||
if (typeof entry?.file !== 'string') continue
|
||||
// 대상(audience)에 맞지 않는 pack 은 건너뛴다(일반=public, 개발자용=non-public).
|
||||
if (!isPackVisibleForAudience(entry.public, audience)) continue
|
||||
const packUrl = `${state.baseUrl}/manifest.json`.replace(/manifest\.json$/, `manifest/${entry.file}.json`)
|
||||
try {
|
||||
const raw = await fetchJson<Partial<PackDefinition>>(packUrl)
|
||||
@@ -603,83 +628,10 @@ ipcMain.handle('server:install', async (_event, payload: ServerInstallPayload) =
|
||||
await downloadServerZip(pack.pack, installPath)
|
||||
// 다운로드한 zip에 들어있을 수 있는 eula.txt를 그대로 보존한다.
|
||||
// 동의 흐름은 renderer가 별도 IPC로 읽고 동의 시 덮어쓴다.
|
||||
|
||||
// run.bat 에 서버 기동/종료시 UPnP 자동 등록/해제 로직 주입.
|
||||
// 이렇게 해야 서버가 안 떠 있는 동안에는 포트가 닫혀 있게 된다.
|
||||
await injectUpnpToRunBat(installPath)
|
||||
// 설치기는 포트를 직접 열지 않는다(요청). run.bat 에 UPnP 자동 개방을 주입하지
|
||||
// 않으며, 사용자가 라우터에서 수동 포워딩을 하고 포트포워딩 페이지에서 확인만 한다.
|
||||
})
|
||||
|
||||
/**
|
||||
* 추출된 서버 zip 의 run.bat 에 UPnP 자동 등록(서버 시작 시) / 자동 해제(서버 종료 후)
|
||||
* 스크립트를 끼워 넣는다. 이미 우리가 주입했던 마커가 있으면 다시 건드리지 않는다.
|
||||
*
|
||||
* 동작:
|
||||
* 1) 서버 시작 직전: server.properties 의 server-port 값(없으면 25565) 으로 PowerShell
|
||||
* 을 통해 HNetCfg.NATUPnP.1 COM 객체를 이용해 정적 포트 매핑 추가.
|
||||
* 2) 서버 프로세스 종료 후(=pause 직전 또는 파일 끝): 동일한 포트의 매핑 제거.
|
||||
*
|
||||
* 제한: 사용자가 콘솔 창을 X 버튼으로 강제 종료하면 teardown 이 실행되지 않는다.
|
||||
* 이 경우 라우터의 UPnP TTL 에 의해 자동 만료되며, 다음 실행 시 Add 전에 Remove 를
|
||||
* 시도하므로 idempotent.
|
||||
*/
|
||||
async function injectUpnpToRunBat(installPath: string): Promise<void> {
|
||||
const runBat = path.join(installPath, 'run.bat')
|
||||
if (!fs.existsSync(runBat)) {
|
||||
sendLog(t('log.runBatMissing'))
|
||||
return
|
||||
}
|
||||
const MARKER = 'REM === UPNP MANAGED BY MUSICQUIZ INSTALLER ==='
|
||||
const original = await fsp.readFile(runBat, 'utf8')
|
||||
if (original.includes(MARKER)) {
|
||||
sendLog(t('log.runBatAlreadyInjected'))
|
||||
return
|
||||
}
|
||||
|
||||
const lines = original.split(/\r?\n/)
|
||||
const javaIdx = lines.findIndex((line) => /^\s*java(\.exe)?[\s"]/i.test(line))
|
||||
if (javaIdx === -1) {
|
||||
sendLog(t('log.runBatNoJava'))
|
||||
return
|
||||
}
|
||||
let pauseIdx = -1
|
||||
for (let i = javaIdx + 1; i < lines.length; i++) {
|
||||
if (/^\s*pause\b/i.test(lines[i])) { pauseIdx = i; break }
|
||||
}
|
||||
if (pauseIdx === -1) pauseIdx = lines.length
|
||||
|
||||
|
||||
// PowerShell 한 줄로 처리: server.properties 의 server-port 우선, 없으면 25565.
|
||||
// Add 전에 같은 포트의 매핑이 남아 있으면 먼저 Remove 하여 idempotent 하게 만든다.
|
||||
const addBlock = [
|
||||
MARKER,
|
||||
'REM 서버 시작 직전: server-port 추출 후 UPnP 매핑 등록.',
|
||||
'set "_MQ_PORT=25565"',
|
||||
'for /f "tokens=2 delims==" %%a in (\'findstr /b /c:"server-port=" server.properties 2^>nul\') do set "_MQ_PORT=%%a"',
|
||||
'set "_MQ_PORT=%_MQ_PORT: =%"',
|
||||
'echo [MusicQuiz] UPnP 등록 시도: TCP %_MQ_PORT%',
|
||||
'powershell -NoProfile -Command "$port=[int]$env:_MQ_PORT; $ip=(Get-NetIPAddress -AddressFamily IPv4 -PrefixOrigin Dhcp,Manual -ErrorAction SilentlyContinue | Where-Object {$_.IPAddress -notlike \'169.254.*\' -and $_.IPAddress -ne \'127.0.0.1\'} | Select-Object -First 1).IPAddress; if (-not $ip) { Write-Host \'[MusicQuiz] 로컬 IPv4 검색 실패\'; exit 1 }; try { $u = New-Object -ComObject HNetCfg.NATUPnP.1; $c=$u.StaticPortMappingCollection; if ($c) { try { $c.Remove($port,\'TCP\') | Out-Null } catch {}; $c.Add($port,\'TCP\',$port,$ip,$true,\'MusicQuiz Minecraft Server\') | Out-Null; Write-Host (\'[MusicQuiz] UPnP 등록 성공: \' + $ip + \':\' + $port + \' TCP\') } else { Write-Host \'[MusicQuiz] UPnP 컬렉션 사용 불가(라우터 UPnP 꺼짐?)\' } } catch { Write-Host (\'[MusicQuiz] UPnP 등록 실패: \' + $_.Exception.Message) }"'
|
||||
]
|
||||
|
||||
const removeBlock = [
|
||||
'REM 서버 종료 후: UPnP 매핑 해제.',
|
||||
'echo [MusicQuiz] UPnP 해제 시도: TCP %_MQ_PORT%',
|
||||
'powershell -NoProfile -Command "$port=[int]$env:_MQ_PORT; try { $u = New-Object -ComObject HNetCfg.NATUPnP.1; $c=$u.StaticPortMappingCollection; if ($c) { $c.Remove($port,\'TCP\') | Out-Null; Write-Host (\'[MusicQuiz] UPnP 해제 완료: TCP \' + $port) } } catch { Write-Host (\'[MusicQuiz] UPnP 해제 실패: \' + $_.Exception.Message) }"'
|
||||
]
|
||||
|
||||
const merged: string[] = []
|
||||
merged.push(...lines.slice(0, javaIdx))
|
||||
merged.push(...addBlock)
|
||||
merged.push(lines[javaIdx])
|
||||
merged.push(...lines.slice(javaIdx + 1, pauseIdx))
|
||||
merged.push(...removeBlock)
|
||||
merged.push(...lines.slice(pauseIdx))
|
||||
|
||||
// bat 파일은 CRLF 가 안전.
|
||||
const output = merged.join('\r\n')
|
||||
await fsp.writeFile(runBat, output, 'utf8')
|
||||
sendLog(t('log.runBatInjected'))
|
||||
}
|
||||
|
||||
ipcMain.handle('server:readEula', async (_event, installPath: string): Promise<{ exists: boolean; content: string }> => {
|
||||
if (!installPath) return { exists: false, content: '' }
|
||||
const target = path.join(path.resolve(installPath), 'eula.txt')
|
||||
@@ -705,7 +657,12 @@ ipcMain.handle('server:fetchMinecraftEula', async (): Promise<{ url: string; htm
|
||||
|
||||
ipcMain.handle('server:acceptEula', async (_event, installPath: string) => {
|
||||
const target = path.join(installPath, 'eula.txt')
|
||||
await fsp.writeFile(target, `# Generated by music quiz installer\neula=true\n`, 'utf8')
|
||||
const acceptedAt = new Date()
|
||||
await fsp.writeFile(
|
||||
target,
|
||||
`# Generated by music quiz installer\n# EULA accepted at: ${acceptedAt.toISOString()}\neula=true\n`,
|
||||
'utf8',
|
||||
)
|
||||
sendLog(t('log.eulaAccepted'))
|
||||
})
|
||||
|
||||
@@ -860,12 +817,7 @@ ipcMain.handle('server:portForward', async (_event, port: number): Promise<PortF
|
||||
const targetPort = Number.isFinite(port) && port > 0 ? port : 25565
|
||||
sendLog(t('log.portCheckStart', { port: targetPort }))
|
||||
|
||||
// 1차 점검 전에 우리가 이전 실행에서 만든 UPnP 매핑이 남아 있으면 먼저 제거한다.
|
||||
// 이렇게 해야 "사용자 라우터 규칙이 활성화돼서 외부 접근이 가능한 상태" 와 "UPnP 매핑 덕분에 접근 가능한 상태" 가 구별된다.
|
||||
// 사용자 규칙이 비활성/없으면 1차 점검은 false 가 되어 UPnP 시도 단계로 자연스럽게 넘어간다.
|
||||
sendLog(t('log.upnpCleanup'))
|
||||
await removeUpnpMapping(targetPort)
|
||||
|
||||
// 설치기는 포트를 직접 열지 않는다. 외부에서 이미 열려 있는지만 확인한다.
|
||||
// 외부 IP 확보: 공용 API → 실패 시 UPnP 게이트웨이의 외부 IP로 폴백.
|
||||
let externalIp = await detectExternalIpHttp()
|
||||
if (externalIp) {
|
||||
@@ -877,9 +829,9 @@ ipcMain.handle('server:portForward', async (_event, port: number): Promise<PortF
|
||||
else sendLog(t('log.externalIpUpnpFail'))
|
||||
}
|
||||
|
||||
// 1차 점검: 외부에서 이미 접근 가능한지 (서버가 떠 있거나, 우리가 임시 리스너 띄워서 검증).
|
||||
// 외부에서 포트가 닿는지 점검(서버가 떠 있거나, 임시 리스너로 검증).
|
||||
sendLog(t('log.probeStart'))
|
||||
let probe = await probePortFromOutside(targetPort, externalIp)
|
||||
const probe = await probePortFromOutside(targetPort, externalIp)
|
||||
if (!externalIp && probe.detectedIp) externalIp = probe.detectedIp
|
||||
const verdict = probe.reachable === true
|
||||
? t('log.probeVerdictSuccess')
|
||||
@@ -888,47 +840,9 @@ ipcMain.handle('server:portForward', async (_event, port: number): Promise<PortF
|
||||
|
||||
if (probe.reachable === true) {
|
||||
sendLog(t('log.probePreForwarded', { addr: externalIp || t('log.ipUnknown'), port: targetPort }))
|
||||
return { status: 'preForwarded', externalIp, port: targetPort }
|
||||
return { status: 'open', externalIp, port: targetPort }
|
||||
}
|
||||
|
||||
// UPnP 시도.
|
||||
sendLog(t('log.upnpTryOpen', { port: targetPort }))
|
||||
try {
|
||||
await openPortViaUpnp(targetPort)
|
||||
sendLog(t('log.upnpReqOk'))
|
||||
} catch (error) {
|
||||
const msg = (error as Error).message || String(error)
|
||||
sendLog(t('log.upnpTryFail', { message: msg }))
|
||||
return {
|
||||
status: 'upnpFailed',
|
||||
externalIp,
|
||||
port: targetPort,
|
||||
message: t('log.upnpFailDetail', { message: msg })
|
||||
}
|
||||
}
|
||||
|
||||
// NAT 반영 지연을 고려해 최대 3회 재점검.
|
||||
for (let attempt = 1; attempt <= 3; attempt++) {
|
||||
await sleep(1500)
|
||||
sendLog(t('log.upnpRecheck', { attempt }))
|
||||
probe = await probePortFromOutside(targetPort, externalIp)
|
||||
if (!externalIp && probe.detectedIp) externalIp = probe.detectedIp
|
||||
if (probe.reachable === true) {
|
||||
sendLog(t('log.upnpDone', { port: targetPort }))
|
||||
await removeUpnpMapping(targetPort)
|
||||
return { status: 'upnpOk', externalIp, port: targetPort }
|
||||
}
|
||||
}
|
||||
|
||||
// 테스트 목적으로 만든 매핑 정리. 실제 개방은 run.bat 이 담당.
|
||||
sendLog(t('log.upnpCleanupTest'))
|
||||
await removeUpnpMapping(targetPort)
|
||||
|
||||
const reason = probe.reachable === false
|
||||
? t('log.upnpFailReason1')
|
||||
: t('log.upnpFailReason2', { detail: probe.detail })
|
||||
sendLog(reason)
|
||||
return { status: 'upnpFailed', externalIp, port: targetPort, message: reason }
|
||||
return { status: 'notOpen', externalIp, port: targetPort }
|
||||
})
|
||||
|
||||
async function detectExternalIpHttp(): Promise<string> {
|
||||
@@ -1124,64 +1038,6 @@ function fetchIfconfigCoPortOnce(port: number): Promise<IfconfigPortResult> {
|
||||
})
|
||||
}
|
||||
|
||||
function removeUpnpMapping(port: number): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
let settled = false
|
||||
const done = () => { if (!settled) { settled = true; resolve() } }
|
||||
let client: ReturnType<typeof natUpnp.createClient> | null = null
|
||||
try {
|
||||
client = natUpnp.createClient()
|
||||
} catch (err) {
|
||||
sendLog(t('log.upnpClientFailRemove', { message: (err as Error).message }))
|
||||
done()
|
||||
return
|
||||
}
|
||||
const timer = setTimeout(() => {
|
||||
try { client && client.close() } catch {}
|
||||
sendLog(t('log.upnpRemoveTimeout'))
|
||||
done()
|
||||
}, 8000)
|
||||
client.portUnmapping({ public: port, protocol: 'tcp' }, (err: Error | null) => {
|
||||
clearTimeout(timer)
|
||||
try { client && client.close() } catch {}
|
||||
if (err) sendLog(t('log.upnpRemoveAttempt', { message: err.message }))
|
||||
else sendLog(t('log.upnpRemoveDone', { port }))
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function openPortViaUpnp(port: number): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let settled = false
|
||||
const done = (err?: Error) => {
|
||||
if (settled) return
|
||||
settled = true
|
||||
if (err) reject(err)
|
||||
else resolve()
|
||||
}
|
||||
let client: ReturnType<typeof natUpnp.createClient> | null = null
|
||||
try {
|
||||
client = natUpnp.createClient()
|
||||
} catch (err) {
|
||||
done(err as Error)
|
||||
return
|
||||
}
|
||||
const timer = setTimeout(() => {
|
||||
try { client && client.close() } catch {}
|
||||
done(new Error(t('errors.upnpTimeout')))
|
||||
}, 15000)
|
||||
client.portMapping(
|
||||
{ public: port, private: port, ttl: 0, description: 'MusicQuiz Server', protocol: 'tcp' },
|
||||
(error: Error | null) => {
|
||||
clearTimeout(timer)
|
||||
try { client && client.close() } catch {}
|
||||
done(error || undefined)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
@@ -1189,7 +1045,7 @@ function sleep(ms: number): Promise<void> {
|
||||
ipcMain.handle('client:install', async (_event, payload: ClientInstallPayload) => {
|
||||
const pack = state.packs.get(payload.packKey)
|
||||
if (!pack) throw new Error(t('errors.packNotFound2'))
|
||||
const customRoot = path.join(getAppDataDir(), '.mc_custom')
|
||||
const customRoot = path.join(getAppDataDir(), getMcCustomDirName())
|
||||
await fsp.mkdir(path.join(customRoot, 'mods'), { recursive: true })
|
||||
await fsp.mkdir(path.join(customRoot, 'resourcepacks'), { recursive: true })
|
||||
|
||||
@@ -1732,7 +1588,27 @@ ipcMain.handle('finish:startLauncher', async () => {
|
||||
sendLog(t('log.launcherAllFail'))
|
||||
})
|
||||
|
||||
ipcMain.handle('i18n:dict', () => localeDict)
|
||||
// 개발자용 빌드(musicQuizAudience=developer)면 렌더러에 넘기는 사전의 제목 앞에
|
||||
// "(개발자용) " 을 붙여, 창 제목/헤더에 개발자용임을 표시한다.
|
||||
function dictForRenderer(): Record<string, unknown> {
|
||||
// 커스텀 폴더명을 UI 문구에 반영.
|
||||
const base = withCustomDirName(localeDict)
|
||||
if (getAudience() !== 'developer') return base
|
||||
const prefix = '(개발자용) '
|
||||
const appBlock = (base.app ?? {}) as Record<string, unknown>
|
||||
const withPrefix = (v: unknown): unknown =>
|
||||
typeof v === 'string' && !v.startsWith(prefix) ? prefix + v : v
|
||||
return {
|
||||
...base,
|
||||
app: {
|
||||
...appBlock,
|
||||
browserTitle: withPrefix(appBlock.browserTitle),
|
||||
headerTitle: withPrefix(appBlock.headerTitle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle('i18n:dict', () => dictForRenderer())
|
||||
|
||||
ipcMain.handle('app:quit', () => {
|
||||
// 모든 창을 닫고 앱 종료. macOS에서도 종료(설치기는 한 번 쓰고 끝이니 잔류시키지 않음).
|
||||
|
||||
@@ -36,7 +36,8 @@ export interface RamCheckResult {
|
||||
}
|
||||
|
||||
export interface PortForwardResult {
|
||||
status: 'preForwarded' | 'upnpOk' | 'upnpFailed'
|
||||
// 설치기는 포트를 직접 열지 않고 "열려 있는지"만 확인한다.
|
||||
status: 'open' | 'notOpen'
|
||||
externalIp?: string
|
||||
port: number
|
||||
message?: string
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import express from 'express'
|
||||
import session from 'express-session'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
import fsp from 'node:fs/promises'
|
||||
import crypto from 'node:crypto'
|
||||
import {
|
||||
manifestRootPath, manifestDirPath, manifestTermsDirPath,
|
||||
fileDirPath, viewsDirPath, publicDirPath
|
||||
fileDirPath, viewsDirPath, publicDirPath, projectRoot,
|
||||
accountFilePath, accountLocalFilePath
|
||||
} from '../shared/paths.js'
|
||||
import {
|
||||
ensurePackTermsDir, isPublicTermsFile, listTermsWithLabels, loadPackDefinition
|
||||
@@ -25,7 +28,24 @@ const app = express()
|
||||
|
||||
app.set('view engine', 'ejs')
|
||||
app.set('views', viewsDirPath)
|
||||
app.set('trust proxy', 1)
|
||||
// 리버스 프록시 뒤일 때만 켠다. 항상 켜두면 직접 노출 시 X-Forwarded-For 조작으로
|
||||
// req.ip 를 위조해 로그인 rate limit 을 우회할 수 있다. 프록시 뒤라면 TRUST_PROXY=true.
|
||||
app.set('trust proxy', process.env.TRUST_PROXY === 'true' ? 1 : false)
|
||||
|
||||
// 추적되는 account.json(과거 평문 노출)을 gitignore 된 account.local.json 으로 시드한다.
|
||||
// 로컬 파일이 이미 있으면 건드리지 않음. 이후 계정 쓰기/자동 해시 업그레이드는 로컬
|
||||
// 파일에만 반영되어, 재배포로 account.json 을 추적 해제해도 로그인이 유지된다.
|
||||
function seedLocalAccounts(): void {
|
||||
try {
|
||||
if (fs.existsSync(accountLocalFilePath)) return
|
||||
if (!fs.existsSync(accountFilePath)) return
|
||||
fs.copyFileSync(accountFilePath, accountLocalFilePath)
|
||||
fs.chmodSync(accountLocalFilePath, 0o600)
|
||||
} catch {
|
||||
// 실패해도 readAccounts 가 account.json 으로 폴백하므로 치명적이지 않음.
|
||||
}
|
||||
}
|
||||
seedLocalAccounts()
|
||||
|
||||
app.use(express.urlencoded({ extended: true }))
|
||||
app.use(express.json())
|
||||
@@ -38,13 +58,36 @@ app.use((_req, res, next) => {
|
||||
next()
|
||||
})
|
||||
|
||||
// 세션 시크릿: 환경변수 우선, 없으면 하드코딩(위조 위험) 대신 영구 랜덤 시크릿을
|
||||
// 파일로 생성/보관한다(재시작해도 세션 유지). 파일 접근 불가 시엔 프로세스 수명 동안만
|
||||
// 유효한 랜덤값으로 폴백(그래도 하드코딩보다 안전).
|
||||
function resolveSessionSecret(): string {
|
||||
const fromEnv = process.env.SESSION_SECRET
|
||||
if (fromEnv && fromEnv.length >= 16) return fromEnv
|
||||
const secretPath = path.join(projectRoot, '.session-secret')
|
||||
try {
|
||||
if (fs.existsSync(secretPath)) {
|
||||
const existing = fs.readFileSync(secretPath, 'utf8').trim()
|
||||
if (existing.length >= 16) return existing
|
||||
}
|
||||
const generated = crypto.randomBytes(32).toString('hex')
|
||||
fs.writeFileSync(secretPath, generated, { mode: 0o600 })
|
||||
return generated
|
||||
} catch {
|
||||
return crypto.randomBytes(32).toString('hex')
|
||||
}
|
||||
}
|
||||
|
||||
app.use(session({
|
||||
secret: process.env.SESSION_SECRET ?? 'music-quiz-installer-dev-secret',
|
||||
secret: resolveSessionSecret(),
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
cookie: {
|
||||
httpOnly: true,
|
||||
sameSite: 'lax',
|
||||
// HTTPS 전용 배포면 SESSION_COOKIE_SECURE=true 로 secure 쿠키 활성화.
|
||||
// HTTP 접근이 섞이면 로그인 쿠키가 안 실리므로 기본값은 false.
|
||||
secure: process.env.SESSION_COOKIE_SECURE === 'true',
|
||||
maxAge: 1000 * 60 * 60 * 8
|
||||
}
|
||||
}))
|
||||
@@ -143,7 +186,7 @@ app.use((req, res, next) => {
|
||||
})
|
||||
|
||||
// 모드 폴더 안의 .jar 파일 목록을 JSON으로 반환. 설치기가 자동 다운로드용으로 사용.
|
||||
app.get('/file/mods/:folder/index.json', async (req, res) => {
|
||||
app.get('/file/mods/:folder/index.json', async (req, res, next) => {
|
||||
const folder = req.params.folder
|
||||
if (!/^[a-zA-Z0-9_\-]+$/.test(folder)) {
|
||||
res.status(404).json({ files: [] })
|
||||
@@ -162,7 +205,8 @@ app.get('/file/mods/:folder/index.json', async (req, res) => {
|
||||
res.status(404).json({ files: [] })
|
||||
return
|
||||
}
|
||||
throw error
|
||||
// async 핸들러의 throw 는 Express4 가 잡지 못해 unhandledRejection 이 되므로 next 로 위임.
|
||||
next(error)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
48
src/server/password.ts
Normal file
48
src/server/password.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import crypto from 'node:crypto'
|
||||
|
||||
// 운영자 비밀번호 저장/검증. 외부 의존성 없이 Node 내장 scrypt 사용.
|
||||
// 저장 형식: `scrypt$<saltHex>$<hashHex>`. 검증은 항상 상수시간 비교.
|
||||
// 기존 account.json 의 평문 비밀번호는 verifyPassword 가 그대로 검증할 수 있고,
|
||||
// 로그인 성공 시 호출측에서 hashPassword 로 재저장(자동 업그레이드)한다.
|
||||
|
||||
const SCHEME = 'scrypt'
|
||||
const KEY_LEN = 32
|
||||
const SALT_LEN = 16
|
||||
|
||||
export function hashPassword(plain: string): string {
|
||||
const salt = crypto.randomBytes(SALT_LEN)
|
||||
const hash = crypto.scryptSync(plain, salt, KEY_LEN)
|
||||
return `${SCHEME}$${salt.toString('hex')}$${hash.toString('hex')}`
|
||||
}
|
||||
|
||||
export function isHashed(stored: string): boolean {
|
||||
return typeof stored === 'string' && stored.startsWith(`${SCHEME}$`)
|
||||
}
|
||||
|
||||
export function verifyPassword(plain: string, stored: string): boolean {
|
||||
if (typeof stored !== 'string' || stored.length === 0) return false
|
||||
if (isHashed(stored)) {
|
||||
const parts = stored.split('$')
|
||||
if (parts.length !== 3) return false
|
||||
let salt: Buffer
|
||||
let expected: Buffer
|
||||
try {
|
||||
salt = Buffer.from(parts[1], 'hex')
|
||||
expected = Buffer.from(parts[2], 'hex')
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
if (expected.length === 0) return false
|
||||
let derived: Buffer
|
||||
try {
|
||||
derived = crypto.scryptSync(plain, salt, expected.length)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
return derived.length === expected.length && crypto.timingSafeEqual(derived, expected)
|
||||
}
|
||||
// 레거시 평문: 길이 노출을 피하려 양쪽을 sha256 으로 고정 길이화한 뒤 상수시간 비교.
|
||||
const a = crypto.createHash('sha256').update(plain, 'utf8').digest()
|
||||
const b = crypto.createHash('sha256').update(stored, 'utf8').digest()
|
||||
return crypto.timingSafeEqual(a, b)
|
||||
}
|
||||
@@ -8,9 +8,9 @@ indexRouter.get('/', async (_req, res, next) => {
|
||||
const manifest = await readManifest()
|
||||
const definitionMap = new Map<string, Awaited<ReturnType<typeof loadPackDefinition>>>()
|
||||
const keys = await listPackKeys()
|
||||
for (const key of keys) {
|
||||
definitionMap.set(key, await loadPackDefinition(key))
|
||||
}
|
||||
// 팩 정의를 병렬 로드(op.ts 와 동일 패턴). 순차 await 보다 빠름.
|
||||
const definitions = await Promise.all(keys.map((key) => loadPackDefinition(key)))
|
||||
keys.forEach((key, i) => definitionMap.set(key, definitions[i]))
|
||||
const packs = manifest.packs.map((entry) => ({
|
||||
name: entry.name,
|
||||
file: entry.file,
|
||||
|
||||
@@ -16,12 +16,16 @@ import {
|
||||
normalizePackDefinition,
|
||||
normalizePackList,
|
||||
readAccounts,
|
||||
readManifest,
|
||||
renamePack,
|
||||
sanitizePackKey,
|
||||
saveTerm,
|
||||
savePackList,
|
||||
setTermVisibility
|
||||
setPackPublic,
|
||||
setTermVisibility,
|
||||
writeAccounts
|
||||
} from '../../shared/store.js'
|
||||
import { hashPassword, isHashed, verifyPassword } from '../password.js'
|
||||
import { fetchReleaseVersions } from '../../shared/mojang.js'
|
||||
import { fetchPlaylistEntries, fetchVideoMeta, YtDlpUnavailableError } from '../youtube.js'
|
||||
import { requireAuth } from '../middleware/auth.js'
|
||||
@@ -31,6 +35,40 @@ import { buildSongsMcfunction } from '../datapack.js'
|
||||
|
||||
export const opRouter = Router()
|
||||
|
||||
// 로그인 브루트포스 + scrypt CPU 남용 방지용 IP 기준 인메모리 실패 제한.
|
||||
const LOGIN_WINDOW_MS = 15 * 60 * 1000
|
||||
const LOGIN_MAX_FAILS = 10
|
||||
const loginFails = new Map<string, { count: number; first: number; blockedUntil: number }>()
|
||||
|
||||
function loginClientKey(req: { ip?: string; socket?: { remoteAddress?: string } }): string {
|
||||
return req.ip || req.socket?.remoteAddress || 'unknown'
|
||||
}
|
||||
|
||||
/** 차단 중이면 남은 ms, 아니면 0. 접근 시 만료된 항목은 정리. */
|
||||
function loginBlockedMs(key: string): number {
|
||||
const now = Date.now()
|
||||
const entry = loginFails.get(key)
|
||||
if (!entry) return 0
|
||||
if (entry.blockedUntil > now) return entry.blockedUntil - now
|
||||
if (now - entry.first > LOGIN_WINDOW_MS) loginFails.delete(key)
|
||||
return 0
|
||||
}
|
||||
|
||||
function recordLoginFail(key: string): void {
|
||||
const now = Date.now()
|
||||
let entry = loginFails.get(key)
|
||||
if (!entry || now - entry.first > LOGIN_WINDOW_MS) entry = { count: 0, first: now, blockedUntil: 0 }
|
||||
entry.count += 1
|
||||
if (entry.count >= LOGIN_MAX_FAILS) entry.blockedUntil = now + LOGIN_WINDOW_MS
|
||||
loginFails.set(key, entry)
|
||||
// 맵 무한 성장 방지(분산 시도 대비): 상한 초과 시 만료 항목 정리.
|
||||
if (loginFails.size > 5000) {
|
||||
for (const [k, v] of loginFails) {
|
||||
if (v.blockedUntil <= now && now - v.first > LOGIN_WINDOW_MS) loginFails.delete(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pickFirstValue(value: unknown): string {
|
||||
if (Array.isArray(value)) return typeof value[0] === 'string' ? value[0] : ''
|
||||
return typeof value === 'string' ? value : ''
|
||||
@@ -54,13 +92,32 @@ opRouter.get('/op', (req, res) => {
|
||||
|
||||
opRouter.post('/op', async (req, res, next) => {
|
||||
try {
|
||||
const clientKey = loginClientKey(req)
|
||||
const blockedMs = loginBlockedMs(clientKey)
|
||||
if (blockedMs > 0) {
|
||||
res.status(429).render('op/login', {
|
||||
error: t('login.tooManyAttempts', { minutes: Math.ceil(blockedMs / 60000) })
|
||||
})
|
||||
return
|
||||
}
|
||||
const password = pickFirstValue(req.body.password)
|
||||
const accounts = await readAccounts()
|
||||
const matched = accounts.find((entry) => entry.password === password)
|
||||
const matched = accounts.find((entry) => verifyPassword(password, entry.password))
|
||||
if (!matched) {
|
||||
recordLoginFail(clientKey)
|
||||
res.status(401).render('op/login', { error: t('login.wrongPassword') })
|
||||
return
|
||||
}
|
||||
loginFails.delete(clientKey)
|
||||
// 평문으로 저장돼 있던 비밀번호는 로그인 성공 시 scrypt 해시로 자동 업그레이드.
|
||||
if (!isHashed(matched.password)) {
|
||||
try {
|
||||
matched.password = hashPassword(password)
|
||||
await writeAccounts(accounts)
|
||||
} catch {
|
||||
// 업그레이드 실패는 로그인 자체에 영향 주지 않음.
|
||||
}
|
||||
}
|
||||
req.session.userId = matched.id
|
||||
res.redirect('/op/dashboard')
|
||||
} catch (error) {
|
||||
@@ -122,11 +179,15 @@ opRouter.get('/op/dashboard/:packName', requireAuth, async (req, res, next) => {
|
||||
return
|
||||
}
|
||||
const releases = await fetchReleaseVersions()
|
||||
const manifest = await readManifest()
|
||||
const entry = manifest.packs.find((e) => e.file === packKey)
|
||||
const isPublic = entry ? entry.public !== false : true
|
||||
res.render('op/editor', {
|
||||
userId: req.session.userId,
|
||||
packKey,
|
||||
pack: definition,
|
||||
releases
|
||||
releases,
|
||||
isPublic
|
||||
})
|
||||
} catch (error) {
|
||||
next(error)
|
||||
@@ -519,6 +580,9 @@ opRouter.post('/op/dashboard/:packName', requireAuth, async (req, res, next) =>
|
||||
return
|
||||
}
|
||||
const finalKey = await renamePack(packKey, requestedKey, normalized)
|
||||
// 체크박스는 체크됐을 때만 전송되므로, 없으면 비공개(개발자용).
|
||||
const isPublic = pickFirstValue(req.body.isPublic) === 'on' || pickFirstValue(req.body.isPublic) === 'true'
|
||||
await setPackPublic(finalKey, isPublic)
|
||||
res.redirect(`/op/dashboard/${finalKey}`)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
|
||||
@@ -299,7 +299,15 @@ async function runYtDlp(args: string[], makeError: (code: string, detail: string
|
||||
* 단일 영상 URL 의 메타데이터를 가져온다.
|
||||
* `--no-playlist` 로 플레이리스트 URL 이 들어와도 단일 영상 정보만 뽑음.
|
||||
*/
|
||||
/** 운영자 입력 URL 이 yt-dlp 인자(플래그)로 오인되지 않도록 http(s) 스킴만 허용. */
|
||||
function assertHttpUrl(url: string): void {
|
||||
if (!/^https?:\/\//i.test(url.trim())) {
|
||||
throw new Error(t('youtube.invalidUrl'))
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchVideoMeta(url: string): Promise<YtPlaylistEntry | null> {
|
||||
assertHttpUrl(url)
|
||||
const stdout = await runYtDlp(
|
||||
['--dump-json', '--no-warnings', '--no-playlist', '--skip-download', url],
|
||||
(code, detail) => new Error(t('youtube.ytdlpVideoFailed', { code, detail }))
|
||||
@@ -327,6 +335,7 @@ export async function fetchVideoMeta(url: string): Promise<YtPlaylistEntry | nul
|
||||
* `--flat-playlist --dump-json` 출력은 한 줄당 한 JSON.
|
||||
*/
|
||||
export async function fetchPlaylistEntries(url: string): Promise<YtPlaylistEntry[]> {
|
||||
assertHttpUrl(url)
|
||||
const stdout = await runYtDlp(
|
||||
['--flat-playlist', '--dump-json', '--no-warnings', url],
|
||||
(code, detail) => new Error(t('youtube.ytdlpPlaylistFailed', { code, detail }))
|
||||
|
||||
20
src/shared/audience.ts
Normal file
20
src/shared/audience.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// 설치기 "대상(audience)" 구분. 빌드 시 package.json 에 박히는 musicQuizAudience
|
||||
// 값으로 결정한다(electron-builder extraMetadata).
|
||||
// - 'public' : 일반 설치기. manifest 의 public!==false 인 pack 만 노출.
|
||||
// - 'developer' : 개발자용 설치기. public===false 인 pack 만 노출.
|
||||
// 이 모듈은 electron 에 의존하지 않는 순수 로직만 둔다(server 빌드에도 포함되므로).
|
||||
|
||||
export type Audience = 'public' | 'developer'
|
||||
|
||||
export function resolveAudience(raw: unknown): Audience {
|
||||
return raw === 'developer' ? 'developer' : 'public'
|
||||
}
|
||||
|
||||
/**
|
||||
* 주어진 pack 의 public 플래그가 현재 audience 에게 보여야 하는지.
|
||||
* public 미지정(undefined)은 공개로 간주한다(하위호환).
|
||||
*/
|
||||
export function isPackVisibleForAudience(isPublic: boolean | undefined, audience: Audience): boolean {
|
||||
const isPublicPack = isPublic !== false
|
||||
return audience === 'developer' ? !isPublicPack : isPublicPack
|
||||
}
|
||||
@@ -73,7 +73,9 @@ export function createI18n(filePath: string): I18n {
|
||||
* 1. 패키징된 Electron 앱이면 `process.resourcesPath/locales/<component>/ko-kr.json`
|
||||
* 2. `<프로젝트 루트>/locales/<component>/ko-kr.json`
|
||||
*/
|
||||
export function loadComponentI18n(component: 'server' | 'installer' | 'installer-rp' | 'installer-pf'): I18n {
|
||||
export function loadComponentI18n(
|
||||
component: 'server' | 'installer' | 'installer-rp' | 'installer-pf' | 'installer-uninstall'
|
||||
): I18n {
|
||||
// 컴파일된 dist/shared/i18n.js 기준으로 프로젝트 루트는 2단계 위.
|
||||
const projectRoot = path.resolve(__dirname, '..', '..')
|
||||
|
||||
|
||||
@@ -6,7 +6,17 @@ export const projectRoot = path.resolve(__dirname, '..', '..')
|
||||
export const manifestRootPath = path.join(projectRoot, 'manifest.json')
|
||||
export const manifestDirPath = path.join(projectRoot, 'manifest')
|
||||
export const manifestTermsDirPath = path.join(manifestDirPath, 'terms')
|
||||
// 추적되는 account.json(과거 평문 노출)을 대체할, gitignore 된 운영 계정 파일.
|
||||
// readAccounts 는 이 파일을 우선 사용하고, 없을 때만 account.json 을 시드로 읽는다.
|
||||
//
|
||||
// TODO(untrack-after-redeploy): account.json 은 아직 git 추적 상태다. 절대 지금
|
||||
// 같은 커밋에서 `git rm --cached account.json` 하지 말 것 — 서버에 account.local.json
|
||||
// 이 아직 없을 때 시드 소스가 사라져 로그인이 막힌다(chicken-and-egg).
|
||||
// 안전한 순서: (1) 이 커밋 배포 → 서버가 account.local.json(0o600) 자동 생성 확인 →
|
||||
// (2) 그 다음 후속 커밋에서 account.json 추적 해제.
|
||||
// 주의: 추적 해제는 위생일 뿐, 히스토리의 평문 비밀번호는 지워지지 않는다 → 비밀번호 로테이션이 실질 조치.
|
||||
export const accountFilePath = path.join(projectRoot, 'account.json')
|
||||
export const accountLocalFilePath = path.join(projectRoot, 'account.local.json')
|
||||
export const fileDirPath = path.join(projectRoot, 'file')
|
||||
export const fileListDirPath = path.join(fileDirPath, 'list')
|
||||
export const fileDatapacksDirPath = path.join(fileDirPath, 'datapacks')
|
||||
@@ -29,9 +39,43 @@ export function getAppDataDir(): string {
|
||||
return process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config')
|
||||
}
|
||||
|
||||
/** %appdata%/.mc_custom — 음악퀴즈 관련 외부 도구/캐시 보관 디렉터리. */
|
||||
/**
|
||||
* 커스텀 게임 디렉터리의 폴더 이름. 기본은 `.mc_custom` 이지만 환경변수
|
||||
* `MC_CUSTOM_DIR` 로 다른 이름을 지정할 수 있다(.env / .env.build 로 주입).
|
||||
* 경로 구분자·상위경로 이스케이프(`/`, `\`, `..`)는 제거해 항상 %appdata%
|
||||
* 바로 아래 단일 폴더로 강제한다.
|
||||
*/
|
||||
export function getMcCustomDirName(): string {
|
||||
const raw = (process.env.MC_CUSTOM_DIR ?? '').trim()
|
||||
if (!raw) return '.mc_custom'
|
||||
const sanitized = raw.replace(/[\\/]+/g, '').replace(/\.\.+/g, '.')
|
||||
return sanitized || '.mc_custom'
|
||||
}
|
||||
|
||||
/** %appdata%/<MC_CUSTOM_DIR|.mc_custom> — 음악퀴즈 관련 게임 폴더/외부 도구/캐시 보관 디렉터리. */
|
||||
export function getMcCustomDir(): string {
|
||||
return path.join(getAppDataDir(), '.mc_custom')
|
||||
return path.join(getAppDataDir(), getMcCustomDirName())
|
||||
}
|
||||
|
||||
/**
|
||||
* 사전/문자열 구조 안의 리터럴 `.mc_custom` 을 실제 폴더 이름으로 치환한 깊은
|
||||
* 복사본을 돌려준다. 기본값(`.mc_custom`)이면 원본을 그대로 반환한다. 렌더러로
|
||||
* 넘기는 i18n 사전에 적용해 UI 안내 문구가 실제 폴더 이름과 어긋나지 않게 한다.
|
||||
*/
|
||||
export function withCustomDirName<T>(value: T): T {
|
||||
const name = getMcCustomDirName()
|
||||
if (name === '.mc_custom') return value
|
||||
const replace = (v: unknown): unknown => {
|
||||
if (typeof v === 'string') return v.split('.mc_custom').join(name)
|
||||
if (Array.isArray(v)) return v.map(replace)
|
||||
if (v && typeof v === 'object') {
|
||||
const out: Record<string, unknown> = {}
|
||||
for (const [k, val] of Object.entries(v as Record<string, unknown>)) out[k] = replace(val)
|
||||
return out
|
||||
}
|
||||
return v
|
||||
}
|
||||
return replace(value) as T
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@ import fsp from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import {
|
||||
manifestRootPath, manifestDirPath, manifestTermsDirPath,
|
||||
accountFilePath, fileListDirPath
|
||||
accountFilePath, accountLocalFilePath, fileListDirPath
|
||||
} from './paths.js'
|
||||
import type {
|
||||
Manifest, ManifestEntry, PackDefinition, AccountEntry, LoaderType,
|
||||
@@ -18,8 +18,15 @@ export async function readManifest(): Promise<Manifest> {
|
||||
return { packs: [] }
|
||||
}
|
||||
return {
|
||||
packs: parsed.packs.filter((entry): entry is ManifestEntry =>
|
||||
typeof entry?.name === 'string' && typeof entry?.file === 'string')
|
||||
packs: parsed.packs
|
||||
.filter((entry): entry is ManifestEntry =>
|
||||
typeof entry?.name === 'string' && typeof entry?.file === 'string')
|
||||
.map((entry) => ({
|
||||
name: entry.name,
|
||||
file: entry.file,
|
||||
// public 은 명시적 boolean 만 보존. 미지정은 그대로 undefined(=공개 취급).
|
||||
...(typeof entry.public === 'boolean' ? { public: entry.public } : {})
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
||||
@@ -245,15 +252,32 @@ type ManifestSyncAction = 'add' | 'remove' | 'upsert'
|
||||
|
||||
async function syncManifestWith(key: string, name: string, action: ManifestSyncAction): Promise<void> {
|
||||
const manifest = await readManifest()
|
||||
const existing = manifest.packs.find((entry) => entry.file === key)
|
||||
const filtered = manifest.packs.filter((entry) => entry.file !== key)
|
||||
if (action === 'remove') {
|
||||
await writeManifest({ packs: filtered })
|
||||
return
|
||||
}
|
||||
filtered.push({ name: name || key, file: key })
|
||||
const entry: ManifestEntry = { name: name || key, file: key }
|
||||
// 기존 public 값은 이름 변경/수정(upsert) 시에도 보존. 신규(add)는 기본 공개(true).
|
||||
entry.public = existing && typeof existing.public === 'boolean' ? existing.public : true
|
||||
filtered.push(entry)
|
||||
await writeManifest({ packs: filtered })
|
||||
}
|
||||
|
||||
/** manifest 엔트리의 public(공개 여부) 플래그를 설정한다. */
|
||||
export async function setPackPublic(key: string, isPublic: boolean): Promise<void> {
|
||||
const manifest = await readManifest()
|
||||
let changed = false
|
||||
for (const entry of manifest.packs) {
|
||||
if (entry.file === key) {
|
||||
entry.public = isPublic
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
if (changed) await writeManifest(manifest)
|
||||
}
|
||||
|
||||
function defaultPackList(): PackList {
|
||||
return { musicPlaylistUrl: '', imagePlaylistUrl: '', music: [], images: [] }
|
||||
}
|
||||
@@ -754,14 +778,24 @@ export function isPublicTermsFile(packKey: string, fileName: string): boolean {
|
||||
}
|
||||
|
||||
export async function readAccounts(): Promise<AccountEntry[]> {
|
||||
try {
|
||||
const raw = await fsp.readFile(accountFilePath, 'utf8')
|
||||
const parsed = JSON.parse(raw)
|
||||
if (!Array.isArray(parsed)) return []
|
||||
return parsed.filter((entry): entry is AccountEntry =>
|
||||
typeof entry?.id === 'string' && typeof entry?.password === 'string')
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return []
|
||||
throw error
|
||||
// gitignore 된 account.local.json 우선. 없으면(ENOENT) 추적되는 account.json 을 시드로.
|
||||
for (const filePath of [accountLocalFilePath, accountFilePath]) {
|
||||
try {
|
||||
const raw = await fsp.readFile(filePath, 'utf8')
|
||||
const parsed = JSON.parse(raw)
|
||||
if (!Array.isArray(parsed)) return []
|
||||
return parsed.filter((entry): entry is AccountEntry =>
|
||||
typeof entry?.id === 'string' && typeof entry?.password === 'string')
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue
|
||||
throw error
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
// 운영 계정 저장은 항상 gitignore 된 account.local.json 에만 한다(추적 파일 오염 방지).
|
||||
// 비밀번호(해시) 파일이므로 소유자만 읽기/쓰기(0o600).
|
||||
export async function writeAccounts(accounts: AccountEntry[]): Promise<void> {
|
||||
await fsp.writeFile(accountLocalFilePath, `${JSON.stringify(accounts, null, 2)}\n`, { mode: 0o600 })
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ export interface PackDefinition {
|
||||
export interface ManifestEntry {
|
||||
name: string
|
||||
file: string
|
||||
/**
|
||||
* 공개 여부. true(또는 미지정)면 일반 설치기(간편/리소스팩)에 노출,
|
||||
* false 면 개발자용 설치기에만 노출된다. 하위호환: 값이 없으면 공개로 간주.
|
||||
*/
|
||||
public?: boolean
|
||||
}
|
||||
|
||||
export interface Manifest {
|
||||
|
||||
4
tsconfig.installer-uninstall.json
Normal file
4
tsconfig.installer-uninstall.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src/installer-uninstall/**/*.ts", "src/shared/**/*.ts"]
|
||||
}
|
||||
@@ -30,6 +30,11 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label style="display:flex;align-items:center;gap:10px;margin:8px 0;">
|
||||
<input type="checkbox" name="isPublic" <%= (typeof isPublic === 'undefined' || isPublic) ? 'checked' : '' %> style="width:auto;" />
|
||||
<span>공개 (체크 시 일반 설치기에 표시 / 해제 시 개발자용 설치기에만 표시)</span>
|
||||
</label>
|
||||
|
||||
<div class="gridTwo">
|
||||
<label>
|
||||
<span><%= t('editor.mcVersion') %></span>
|
||||
|
||||
Reference in New Issue
Block a user