feat: per-pack public flag + developer installer variants
manifest.json 의 각 pack 에 public(boolean) 을 추가하고, 대상(audience)별로 설치기를 구분한다. - ManifestEntry.public 추가. 미지정=공개(하위호환). store 가 upsert/rename 시 기존 public 보존, 신규 pack 은 public=true 기본. setPackPublic() 추가. - 사이트 pack 편집기에 "공개" 체크박스 추가(체크=일반, 해제=개발자용). 저장 시 manifest 엔트리 public 갱신, 편집기 진입 시 현재 값 표시. - shared/audience.ts: 빌드의 musicQuizAudience(package.json)로 대상 판별. 일반 설치기=public!==false 만, 개발자용=public===false 만 노출. - 간편/리소스팩 설치기 packs 로드에서 audience 필터 적용. - 개발자용 빌드 구성(electron-builder-dev.yml, electron-builder-rp-dev.yml)과 dist:win:dev / dist:win:rp:dev 스크립트 추가(artifact: *-Dev-*). v0.3.20. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
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
|
||||
}
|
||||
@@ -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: [] }
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ export interface PackDefinition {
|
||||
export interface ManifestEntry {
|
||||
name: string
|
||||
file: string
|
||||
/**
|
||||
* 공개 여부. true(또는 미지정)면 일반 설치기(간편/리소스팩)에 노출,
|
||||
* false 면 개발자용 설치기에만 노출된다. 하위호환: 값이 없으면 공개로 간주.
|
||||
*/
|
||||
public?: boolean
|
||||
}
|
||||
|
||||
export interface Manifest {
|
||||
|
||||
Reference in New Issue
Block a user