designpaca/apps/site/tools/capture-work-shots.mjs
Yun Chan 2b7fa32b5b
All checks were successful
ci / build (push) Successful in 51s
release / release (push) Successful in 2m34s
feat: 한국어 우선 쇼케이스 정리
2026-08-26 18:14:41 +09:00

75 lines
3.2 KiB
JavaScript

// 관리 앱 2종(가온·두레) 전용 캡처 — 쇼케이스 카드 2컷(본컷 + 모달 -2컷)과 og.png.
// capture-shots.mjs 는 CLI 크롬이라 모달을 열 수 없어 이 스크립트가 -2컷을 담당한다.
import puppeteer from "puppeteer-core";
import path from "node:path";
import url from "node:url";
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const root = path.resolve(__dirname, "..");
const CHROME = "C:/Program Files/Google/Chrome/Application/chrome.exe";
const shots = path.join(root, "src", "assets", "shots");
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
function requestedSlugs(argv) {
const slugs = new Set();
for (let index = 2; index < argv.length; index += 1) {
const argument = argv[index];
if (argument === "--slug") {
const slug = argv[index + 1];
if (!slug) throw new Error("--slug requires an app slug");
slugs.add(slug);
index += 1;
} else if (argument.startsWith("--slug=")) {
slugs.add(argument.slice("--slug=".length));
} else {
throw new Error(`Unknown argument: ${argument}`);
}
}
return slugs;
}
const requested = requestedSlugs(process.argv);
const known = new Set(["gaon-lms", "dure-enrollment"]);
const unknown = [...requested].filter((slug) => !known.has(slug));
if (unknown.length) throw new Error(`Unknown app slug(s): ${unknown.join(", ")}`);
const selected = requested.size ? requested : known;
const browser = await puppeteer.launch({
executablePath: CHROME,
headless: "new",
args: ["--no-sandbox", "--disable-gpu", "--force-device-scale-factor=1"],
defaultViewport: { width: 1440, height: 900 },
});
const page = await browser.newPage();
await page.setCacheEnabled(false);
const open = async (app) => {
await page.goto(url.pathToFileURL(path.join(root, "public/work", app, "index.html")).href, { waitUntil: "networkidle0" });
await page.evaluate(() => document.fonts.ready);
await sleep(250);
};
if (selected.has("gaon-lms")) {
// 가온: 대시보드 본컷 + 학적 카드(수강생 모달) -2컷
await open("gaon-lms");
await page.screenshot({ path: path.join(shots, "work-gaon-lms.png") });
await page.screenshot({ path: path.join(root, "public/work/gaon-lms/og.png") });
await page.evaluate(() => document.querySelector('[data-view="students"]').click());
await page.evaluate(() => document.querySelector("#stu-table [data-stu]").click());
await page.waitForSelector("#stu-dialog[open]");
await sleep(350); // 모달 등장 모션 200ms + 여유
await page.screenshot({ path: path.join(shots, "work-gaon-lms-2.png") });
}
if (selected.has("dure-enrollment")) {
// 두레: 과목 찾기 본컷 + 강의계획(과목 모달) -2컷
await open("dure-enrollment");
await page.screenshot({ path: path.join(shots, "work-dure-enrollment.png") });
await page.screenshot({ path: path.join(root, "public/work/dure-enrollment/og.png") });
await page.evaluate(() => document.querySelector(".course-row").click());
await page.waitForSelector("#course-dialog[open]");
await sleep(350);
await page.screenshot({ path: path.join(shots, "work-dure-enrollment-2.png") });
}
await browser.close();
console.log("work shots + og.png 갱신 완료");