39 lines
1.7 KiB
JavaScript
39 lines
1.7 KiB
JavaScript
/* 455 (433-13 ③) 옛 정책 경고 — 진짜 `B05_Profile_UI_Profile_Data.ts` readAlignment +
|
|
* `B05_Profile_UI_Profile_Alignment.ts` buildAlignment 를 Node 로 돌림.
|
|
* 입력 argv[2] = 종단 정본 JSON · 표준출력 = { warnings: [법정 미달 글], policy }.
|
|
*/
|
|
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();
|
|
function loadTs(file) {
|
|
const full = path.resolve(file);
|
|
if (cache.has(full)) return cache.get(full);
|
|
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const box = { exports: {} };
|
|
cache.set(full, box.exports);
|
|
const localRequire = (request) => {
|
|
if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
|
|
return require(request);
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
return box.exports;
|
|
}
|
|
|
|
const LOGIC = path.join(ROOT, "B05_Profile", "logic");
|
|
const data = loadTs(path.join(LOGIC, "B05_Profile_UI_Profile_Data.ts"));
|
|
const align = loadTs(path.join(LOGIC, "B05_Profile_UI_Profile_Alignment.ts"));
|
|
const longitudinal = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
const stored = data.readAlignment(longitudinal);
|
|
const built = align.buildAlignment(align.toAlignmentBase(stored), align.emptyEdits());
|
|
process.stdout.write(
|
|
JSON.stringify({
|
|
warnings: built.warnings.filter((text) => text.includes("법정 최소")),
|
|
policy: stored.policy,
|
|
}),
|
|
);
|