feat: 날씨 유형 그림 8장·미리보기 그림 9장, 한글 사용자 폴더에서 그림 도구가 멈추던 것 고침

- 유형 그림 8장(800×800 webp): 임시 그림을 Codex 로 그린 그림으로 교체 — 같은 토끼가 유형별 날씨 장면에
- 미리보기 그림 9장(1200×630 png)을 새 그림으로 다시 만듦
- 그림 프롬프트 admin/image-prompts/weather-type.json 추가 (다시 그려도 같은 그림체)
- admin/scripts/bin.mjs: 윈도우에서 프로그램 위치를 PATH 로 직접 찾음 (where 출력은 경로의 한글이 깨짐),
  .cmd 가 .exe 를 가리키는 경우(npm 으로 깐 claude)도 부름
- admin/scripts/bin.mjs removeDir: 경로에 한글이 있으면 rmSync(recursive) 가 Node 를 꺼뜨려(종료 코드 127)
  그림 한 장만 만들고 끝나던 것 — 하나씩 지우게
- admin 테스트 추가 (admin 에서 npm test)
This commit is contained in:
skkim committed 2026-11-24 09:11:54 +09:00
1 parent 4fc61d6c02
commit 11a7a270ff
23 files changed
+147 -17

No files matched your search

+1 -1
View File
@@ -473,7 +473,7 @@ docs를 6개로 합칠 때 옛 내용을 그대로 옮겼다. 아래는 코드
| 상태 | 할 일 | 이유 | 관련 파일 |
|---|---|---|---|
| [ ] | 유형 그림 8장(정사각형) 넣고 미리보기 그림 9장(1200×630) 다시 만들기 — 지금은 '임시 그림'이라 적힌 자리 표시. 그림 없이 배포하지 않음 | 11/23 결정: 타로·사주처럼 새로 그림 | `frontend/public/type/`, `frontend/public/type/og/` |
| [x] | 유형 그림 8장(정사각형)·미리보기 그림 9장(1200×630) — 11/24 Codex로 생성(같은 토끼가 유형별 날씨 장면에, 프롬프트 `admin/image-prompts/weather-type.json`). 다시 그리면 800×800 webp 로 줄여 넣고 미리보기 그림도 다시 만든다. 사용자 그림 확인 남음 | 11/23 결정: 타로·사주처럼 새로 그림, 11/24 사용자 요청으로 생성 | `frontend/public/type/`, `frontend/public/type/og/` |
| [ ] | 배포 뒤 카카오톡 등 실제 메신저에서 유형별 미리보기(제목·그림)가 뜨는지, 휴대폰 공유창으로 보내고 닫는 것까지 확인 | 로컬에서는 빌드된 HTML 값과 PC 크롬의 주소 복사만 확인 | `frontend/vite.config.ts`, `frontend/src/lib/linkShare.ts` |
| [ ] | 토스: `.ait` 다시 올리고, 토스 앱에서 공유 링크(`intoss://nalssigak/type/유형`)가 그 결과 화면으로 열리는지·미리보기 그림이 유형별로 뜨는지 확인. 안 열리면 토스에서는 입구(오늘 탭 아이콘)를 숨김 | 토스 공식 문서·SDK 로만 확인, 실기기 미확인. 미리보기 그림은 토스 안드로이드 5.240.0·iOS 5.239.0 이상 | `frontend/src/lib/platform.ts` `shareLink` |
| [ ] | 배포 뒤 인스타 카드·쇼츠로 테스트 알리기 | 처음 퍼뜨릴 사람이 적음 | |
+38
View File
@@ -0,0 +1,38 @@
{
"about": "날씨 유형 테스트(frontend /type) 결과 카드 그림. 유형(frontend/seo/weather_type.json)마다 한 장, 같은 토끼가 그 날씨 장면에 있는 정사각형 그림. `npm run gen-image -- weather-type <slug>` 로 만들면 src/assets/weather-type/<slug>.webp 가 나오고, 이걸 800×800 으로 줄여 frontend/public/type/<slug>.webp 로 옮긴다(관리자 쪽 사본은 두지 않는다). 화면에서는 위아래가 12%쯤 잘린 4:3 으로 보이므로 토끼와 중요한 물건은 가운데 높이 70% 안에 둔다.",
"style": "Use case: stylized-concept. Asset type: text-free SQUARE (1:1) character illustration for a playful Korean weather personality test result card. Full-bleed scene filling the entire canvas edge to edge, no card border, no frame, no vignette. Main character: ONE cute white rabbit clay toy (simple black dot eyes, tiny pink nose, pink inner ears, round chubby body, no human face), the same mascot in every image, shown full body, large, in the center. Scene: {motif}. Composition: the rabbit and every key object stay inside the middle 70% of the canvas height; the top 15% and the bottom 15% contain only plain sky or plain ground because they will be cropped away. One clear readable scene, simple background, not cluttered. Style: tactile matte clay / soft vinyl 3D illustration, chunky rounded shapes, bright cheerful palette with ivory #f7fbff and deep ink #28304a accents, soft studio light. No humans, no other animals. Text: none. Absolutely NO letters, words, numbers, labels, logos, watermark or pseudo-text anywhere.",
"items": [
{
"id": "sonagi",
"motif": "a sudden summer shower that is already clearing: the rabbit joyfully jumping in a puddle with a big splash, chunky clay raindrops falling from one dark blue cloud on the left while warm sunlight and a small rainbow break through on the right; dominant color soft blue #4f97e3; mood: bursts out strongly and clears up fast"
},
{
"id": "bombyeot",
"motif": "gentle spring sunshine: the rabbit sitting on a soft green meadow with eyes happily closed, basking in warm light, holding a small flower, a soft round pale sun above, a few clay blossoms and a butterfly-shaped petal drifting; dominant color warm yellow #f5c84b with fresh green; mood: makes everyone nearby feel warm"
},
{
"id": "angae",
"motif": "a quiet misty morning: the rabbit standing calmly and holding a small glowing lantern, soft layers of lavender fog drifting around low hills and a few round trees fading into the mist, gentle glow around the lantern; dominant color soft lavender #b3a6dc; mood: quiet, thoughtful and deep"
},
{
"id": "baram",
"motif": "a light fresh breeze: the rabbit walking lightly on a grassy hill with a long mint scarf fluttering sideways, holding a spinning pinwheel, chunky clay swirl shapes of wind and dandelion seeds floating past in a clear sky; dominant color mint green #7fd1b9; mood: easygoing, free and light"
},
{
"id": "taeyang",
"motif": "blazing midday sun: the rabbit standing proudly with both arms raised high and a big confident smile, a huge chunky clay sun with thick rays right behind it like a halo, bright clear sky, a tiny sunflower on each side; dominant color warm orange #ff7a45 with golden yellow; mood: energetic, bold, the center of attention"
},
{
"id": "cheonnun",
"motif": "the first snow of the year at dusk: the rabbit wearing a small pink scarf, looking up in delight and reaching out both paws to catch big fluffy clay snowflakes, soft pink and lilac evening sky, a tiny warm street lamp glowing beside it, a thin layer of fresh snow on the ground; dominant color soft pink #f4a6c0; mood: excited, romantic, sentimental"
},
{
"id": "gureum",
"motif": "a lazy fair-weather afternoon: the rabbit lying on its tummy and napping happily on top of one big fluffy white cumulus cloud that floats in the middle of a pale blue sky, a couple of smaller round clouds drifting behind; dominant color pale gray-blue #b9c8e0 with fluffy white; mood: relaxed, unhurried, soft"
},
{
"id": "beongae",
"motif": "a flash of lightning: the rabbit dashing forward at full speed in a dynamic running pose with a determined grin, one big chunky bright yellow clay lightning bolt striking down behind it from a deep purple storm cloud, small star-shaped sparks around its feet; dominant color bright yellow #f6d21f against deep purple; mood: quick, decisive, electric"
}
]
}
+2 -1
View File
@@ -10,7 +10,8 @@
"preview": "vite preview",
"api": "openapi-ts",
"card": "node scripts/card.mjs",
"gen-image": "node scripts/gen-image.mjs"
"gen-image": "node scripts/gen-image.mjs",
"test": "node --test"
},
"dependencies": {
"@tailwindcss/vite": "^4.3.3",
+24 -11
View File
@@ -1,6 +1,6 @@
// 외부 프로그램(크롬·claude·codex·ffmpeg) 위치와 부르는 법. 맥·윈도우 둘 다에서 돌게 한 곳에 모은다.
import { execFileSync } from 'node:child_process'
import { existsSync, readFileSync } from 'node:fs'
import { existsSync, readdirSync, readFileSync, rmdirSync, unlinkSync } from 'node:fs'
import { dirname, join } from 'node:path'
const WIN = process.platform === 'win32'
@@ -15,24 +15,37 @@ export const CHROME =
/**
* execFile 로 부를 [실행 파일, ...앞 인자]. CLAUDE_BIN·CODEX_BIN 환경변수로 바꿀 수 있다.
* 윈도우에서 npm 으로 깐 CLI 는 .cmd 라 shell 없이는 못 부르므로(인자 따옴표가 깨짐) .cmd 가 가리키는 .js 를 node 로 직접 부른다.
* 윈도우에서 npm 으로 깐 CLI 는 .cmd 라 shell 없이는 못 부르므로(인자 따옴표가 깨짐) .cmd 가 가리키는 .js 를 node 로, .exe 는 그대로 직접 부른다.
*/
export function cli(name) {
const override = process.env[`${name.toUpperCase()}_BIN`]
if (override) return [override]
if (!WIN) return [name]
let hits = []
try {
hits = execFileSync('where', [name], { encoding: 'utf8' }).split(/\r?\n/).filter(Boolean)
} catch {
throw new Error(`${name} 을(를) 찾지 못했어요. 설치했는지 보고, ${name.toUpperCase()}_BIN 환경변수로 실행 파일 경로를 알려 주세요.`)
}
// PATH 를 직접 훑는다: `where` 의 출력은 윈도우 코드 페이지(한국어 CP949)라, 경로에 한글이 있으면(사용자 폴더 이름) utf8 로 읽을 때 깨진다
const dirs = (process.env.PATH ?? '').split(';').filter(Boolean)
const hits = dirs.flatMap((dir) => ['.exe', '.cmd'].map((ext) => join(dir, name + ext))).filter((p) => existsSync(p))
if (hits.length === 0) throw new Error(`${name} 을(를) 찾지 못했어요. 설치했는지 보고, ${name.toUpperCase()}_BIN 환경변수로 실행 파일 경로를 알려 주세요.`)
const exe = hits.find((p) => p.toLowerCase().endsWith('.exe'))
if (exe) return [exe]
const shim = hits.find((p) => p.toLowerCase().endsWith('.cmd'))
const js = shim && readFileSync(shim, 'utf8').match(/%dp0%\\([^"]+?\.js)/)?.[1]
if (!js) throw new Error(`${name} 실행 파일(${hits.join(', ')})을 부를 수 없어요. ${name.toUpperCase()}_BIN 환경변수로 .exe 경로를 알려 주세요.`)
return [process.execPath, join(dirname(shim), js)]
// .cmd 의 실제로 부르는 줄("…" %*)은 옆 node_modules 의 .js(codex) 나 .exe(claude) 를 가리킨다
const target = shim && readFileSync(shim, 'utf8').match(/%dp0%\\([^"]+?\.(?:js|exe))"\s+%\*/)?.[1]
if (!target) throw new Error(`${name} 실행 파일(${hits.join(', ')})을 부를 수 없어요. ${name.toUpperCase()}_BIN 환경변수로 .exe 경로를 알려 주세요.`)
const path = join(dirname(shim), target)
return target.endsWith('.exe') ? [path] : [process.execPath, path]
}
/**
* 폴더를 안의 것까지 지운다.
* rmSync(dir, { recursive: true }) 는 윈도우에서 경로에 한글이 있으면(사용자 폴더 이름이 한글인 PC 의 임시 폴더) Node 가 오류도 없이 꺼져서(v24.12, 종료 코드 127) 하나씩 지운다
*/
export function removeDir(dir) {
for (const entry of readdirSync(dir, { withFileTypes: true })) {
const path = join(dir, entry.name)
if (entry.isDirectory()) removeDir(path)
else unlinkSync(path)
}
rmdirSync(dir)
}
/** png → jpg (품질 높게) */
+4 -4
View File
@@ -1,9 +1,9 @@
// Codex CLI의 이미지 생성 도구로 그림 한 장을 만들어 webp 로 저장한다. gen-image.mjs(고정 데이터 그림)와 daily-ootd.mjs(그날 코디 그림)가 같이 쓴다.
import { execFileSync } from 'node:child_process'
import { mkdtempSync, readdirSync, rmSync } from 'node:fs'
import { mkdtempSync, readdirSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { cli, toWebp } from './bin.mjs'
import { cli, removeDir, toWebp } from './bin.mjs'
// 그림은 이미지 생성 도구가 만들고 Codex 는 도구를 부르고 결과를 저장하는 역할뿐이라 중간 모델·낮은 추론으로 고정한다 (가장 싼 gpt-6-luna 는 결과를 파일로 저장하지 못하고, 기본 설정의 gpt-6-astra·xhigh 는 한도를 금방 소진한다)
export const IMAGE_MODEL = process.env.CODEX_IMAGE_MODEL ?? 'gpt-6-sol'
@@ -31,7 +31,7 @@ export function drawWithCodex({ id, prompt, outPath, images = [], log = console.
const [codex, ...pre] = cli('codex')
execFileSync(codex, [...pre, 'exec', '--skip-git-repo-check', '-C', work, '-s', 'workspace-write', '-m', IMAGE_MODEL, '-c', 'model_reasoning_effort="low"', ...imageArgs], { input: task, stdio: ['pipe', 'ignore', 'inherit'] })
} catch (e) {
rmSync(work, { recursive: true, force: true })
removeDir(work)
throw new Error(`${id}: Codex 실행이 실패했어요 (${e.message}). 사용 한도나 로그인을 확인하세요.`)
}
const png = readdirSync(work).find((f) => f === 'result.png') ?? readdirSync(work).find((f) => f.endsWith('.png'))
@@ -40,7 +40,7 @@ export function drawWithCodex({ id, prompt, outPath, images = [], log = console.
return 'not-saved'
}
toWebp(join(work, png), outPath)
rmSync(work, { recursive: true, force: true })
removeDir(work)
log(`${id}: ${outPath}`)
return 'ok'
}
+78
View File
@@ -0,0 +1,78 @@
// 외부 프로그램 찾기·작업 폴더 지우기 검증 (윈도우 사용자 폴더 이름이 한글이면 깨지던 것). 실행: admin 폴더에서 npm test
import assert from 'node:assert/strict'
import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { test } from 'node:test'
import { cli, removeDir } from '../scripts/bin.mjs'
const WIN = process.platform === 'win32'
const koreanDir = () => mkdtempSync(join(tmpdir(), '한글-폴더-'))
/** PATH 맨 앞에 dir 을 둔 채로 run 을 돌리고 되돌린다 */
function withPath(dir, run) {
const before = process.env.PATH
process.env.PATH = `${dir};${before}`
try {
return run()
} finally {
process.env.PATH = before
}
}
test('removeDir 는 경로에 한글이 있어도 안의 파일·폴더까지 지운다', () => {
const dir = koreanDir()
mkdirSync(join(dir, '안쪽'))
writeFileSync(join(dir, '안쪽', 'result.png'), 'x')
writeFileSync(join(dir, 'result.png'), 'x')
removeDir(dir)
assert.equal(existsSync(dir), false)
})
test('한글 이름 폴더에 깔린 .cmd 프로그램은 그 .cmd 가 가리키는 .js 를 node 로 부른다', { skip: !WIN }, () => {
const dir = koreanDir()
// npm 이 만드는 .cmd 모양: 옆에 node.exe 가 있는지 먼저 보는 줄이 있고, 마지막 줄이 실제로 부르는 줄이다
writeFileSync(
join(dir, 'faketool-cmd.cmd'),
'@ECHO off\r\nIF EXIST "%dp0%\\node.exe" (\r\n SET "_prog=%dp0%\\node.exe"\r\n) ELSE (\r\n SET "_prog=node"\r\n)\r\n"%_prog%" "%dp0%\\node_modules\\fake\\bin\\fake.js" %*\r\n',
)
try {
assert.deepEqual(withPath(dir, () => cli('faketool-cmd')), [process.execPath, join(dir, 'node_modules\\fake\\bin\\fake.js')])
} finally {
removeDir(dir)
}
})
test('.cmd 가 .exe 를 가리키면(npm 으로 깐 claude) 그 .exe 를 부른다', { skip: !WIN }, () => {
const dir = koreanDir()
writeFileSync(join(dir, 'faketool-shim.cmd'), '@ECHO off\r\n"%dp0%\\node_modules\\fake\\bin\\fake.exe" %*\r\n')
try {
assert.deepEqual(withPath(dir, () => cli('faketool-shim')), [join(dir, 'node_modules\\fake\\bin\\fake.exe')])
} finally {
removeDir(dir)
}
})
test('.exe 가 있으면 .cmd 보다 .exe 를 부른다', { skip: !WIN }, () => {
const dir = koreanDir()
writeFileSync(join(dir, 'faketool-exe.cmd'), '"%dp0%\\node_modules\\fake\\bin\\fake.js" %*\r\n')
writeFileSync(join(dir, 'faketool-exe.exe'), '')
try {
assert.deepEqual(withPath(dir, () => cli('faketool-exe')), [join(dir, 'faketool-exe.exe')])
} finally {
removeDir(dir)
}
})
test('프로그램이 없으면 환경변수로 알려 달라는 오류를 낸다', { skip: !WIN }, () => {
assert.throws(() => cli('faketool-none'), /FAKETOOL-NONE_BIN/)
})
test('환경변수로 준 경로가 있으면 그대로 쓴다', () => {
process.env.FAKETOOL_BIN = 'C:/어딘가/faketool.exe'
try {
assert.deepEqual(cli('faketool'), ['C:/어딘가/faketool.exe'])
} finally {
delete process.env.FAKETOOL_BIN
}
})
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 33 KiB