Files
Aislo/resources/tester/helper_52_4_ford.cjs
T
eomsangdonandClaude Opus 5.5 281c71b55b refactor(logic): 348-1 순수 계산 TS 49 파일 <페이지>/logic/ 로 옮김 — 이름 앞머리 그대로 · 동작 고침 없음
- 옮김: B04 2 · B05 23 · B06 11 · A00_Common/design 13 (9,299 줄) · 이미 logic/ 에 있던 16 파일 그대로
- 안 옮김: 묶음 입구(package.json build:*) · 파이썬 · 순수지만 계산 아닌 8 (보기 결선 · 콜백 · API 타입 · 갈아끼움 알림판)
- import 266 줄(142 파일) · 시험 · 주석 · 짝 표시 문자열 경로 고침 · B05 · B06 CLAUDE.md 짝 줄 logic/
- 시험 도우미 새 경로: 가짜 require 열쇠 · B05()/B06() 부름 · 형제 import 자리 · tsc 묶어 돌리는 시험 · 정규식 · rglob
- design_view_cross 줄 한도 시험 685 → 688 (긴 import 경로 줄바꿈 3줄)
- 확인: typecheck 0 · 서버 묶음 넷(corridor · server-calc · b07-extent · b07-note) 다시 지어 코드 같음(//#region 경로 주석만 다름) · 관련 시험 270 파일 — 남은 실패 19 는 옮기기 전과 같음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
2026-10-16 13:44:50 +09:00

87 lines
3.5 KiB
JavaScript

/* 세월교 명세(표 04) · 월류 폭 ↔ 높이 계산 단위검증 헬퍼(PLAN 52-4) — `design_structure_spec.ts` ·
* `design_structure_ford.ts` · `design_structure_ford_calc.ts`(+ `fordSection` 이 든 B05 칸 조각)를 그 자리에서
* 트랜스파일해 Node 로 돌림. 결과 = JSON 한 벌. 인자 `names` 면 세월교 이름 표(정의 `종류.ford_bridge.이름`)만 냄.
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
const cache = new Map();
/** TS 한 파일을 CommonJS 로 — 상대 import 는 그 파일 자리 기준 · `@config/` 는 config 폴더 · .json 은 그대로. */
const load = (file) => {
if (cache.has(file)) return cache.get(file);
if (file.endsWith(".json")) return JSON.parse(fs.readFileSync(file, "utf8"));
const js = ts.transpileModule(fs.readFileSync(file, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
cache.set(file, box.exports);
const near = (m) => {
const base = m.startsWith("@config/")
? path.join(ROOT, "config", m.slice(8))
: path.join(path.dirname(file), m);
return load(base.endsWith(".json") ? base : `${base}.ts`);
};
new Function("exports", "module", "require", js)(box.exports, box, near);
cache.set(file, box.exports);
return box.exports;
};
const D = (f) => path.join(ROOT, "A00_Common", "design", f);
const s = load(D("logic/design_structure_spec.ts"));
const { FORD_SPEC, withLegacyGuards } = load(D("logic/design_structure_ford.ts"));
const calc = load(D("design_structure_ford_calc.ts"));
if (process.argv[2] === "names") {
process.stdout.write(JSON.stringify(s.nameTable(FORD_SPEC)));
process.exit(0);
}
const old = {
pipe_kind: "파형강관",
pipe_diameter_mm: 1000,
pipe_count: 2,
ford_width_m: 10,
ford_height_m: 0.3,
wing_in: "있음",
wing_in_height_m: 1,
wing_out: "없음",
};
const legacy = withLegacyGuards(old);
const state = s.readState(FORD_SPEC, legacy);
const back = s.writeOptions(FORD_SPEC, state);
const soil = JSON.parse(JSON.stringify(state));
soil.inlet[0].structure = "흙막이";
soil.outlet[0].structure = "날개벽";
const soilOut = s.writeOptions(FORD_SPEC, soil);
const flows = [0.5, 2.54, 8];
const widths = [3, 5, 10, 20];
const table = flows.flatMap((q) => widths.map((b) => [q, b, calc.fordHeightM(q, b)]));
const out = {
containers: FORD_SPEC.containers.map((c) => [c.id, c.title, c.required]),
items: FORD_SPEC.containers.map((c) => c.items.map((i) => [i.id, i.kind, i.key ?? null])),
choices: FORD_SPEC.containers.map((c) =>
c.items.filter((i) => i.kind === "select").map((i) => s.choicesOf(i, {}).map((ch) => ch.label)),
),
legacy: { inlet: legacy.inlet_type, outlet: legacy.outlet_type },
keepSoil: withLegacyGuards({ inlet_type: "흙막이", wing_in: "없음" }).inlet_type,
b06Off: withLegacyGuards({ inlet_type: "날개벽", wing_in: "없음" }).inlet_type,
b06On: withLegacyGuards({ inlet_type: "없음", wing_in: "있음" }).inlet_type,
state,
back,
soilOut,
links: FORD_SPEC.containers.map((c) => s.linkOf(c, 1)),
keys: s.specKeys(FORD_SPEC),
retired: FORD_SPEC.retired,
table,
none: [calc.fordHeightM(null, 10), calc.fordHeightM(2.54, 0)],
hints: [
calc.fordHeightHint(2.54, 10),
calc.fordHeightHint(2.54, 0),
calc.fordHeightHint(null, 10),
],
};
process.stdout.write(JSON.stringify(out));