28 lines
1.4 KiB
TypeScript
28 lines
1.4 KiB
TypeScript
/* =============================================================================
|
|
* common_util_sheet_recalc_node.ts
|
|
* 표 문서 풀이를 **서버가** 돌리는 진입점 — [저장] 때 정본으로 다시 풂.
|
|
*
|
|
* 풀이는 화면이 쓰는 `ui_template_sheet_recalc.ts` 그대로 — 여기에는 계산이 없음.
|
|
* 파이썬 껍데기 = `common_util_sheet_recalc.py` · 번들 = `npm run build:formula`.
|
|
*
|
|
* 실행: node <번들> <입력.json> <출력.json>
|
|
* 입력 { docs: SheetDoc[] }
|
|
* 출력 { results: SheetResult[] } — 입력 차례 그대로
|
|
* 끝 코드: 0 성공 / 2 인자 오류
|
|
* ⚠ `ui_template/sheet/` 밖에 둠 — M02 화면이 그 폴더를 통째로 훑어 불러옴(node:fs 가 브라우저로 새지 않게).
|
|
* ========================================================================== */
|
|
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import { recalcSheet } from "@ui/sheet/ui_template_sheet_recalc";
|
|
import type { SheetDoc } from "@ui/sheet/ui_template_sheet_types";
|
|
|
|
const [inputPath, outputPath] = process.argv.slice(2);
|
|
if (!inputPath || !outputPath) {
|
|
console.error("사용법: node <번들> <입력.json> <출력.json>");
|
|
process.exit(2);
|
|
}
|
|
|
|
const input = JSON.parse(readFileSync(inputPath, "utf8")) as { docs?: SheetDoc[] };
|
|
const results = (input.docs ?? []).map((doc) => recalcSheet(doc));
|
|
writeFileSync(outputPath, JSON.stringify({ results }));
|