Two follow-up fixes from the Task 5 code-quality review: - scripts/generate-plant-hours-template.ts uses fileURLToPath(import.meta.url) instead of __dirname. The project's tsconfig has module: esnext, so the moment the package flips to ESM the original would throw ReferenceError: __dirname is not defined. - src/lib/plant-hours-template.ts documents that the frozen header row is a best-effort request — SheetJS Community Edition silently drops the !freeze property (only Pro emits frozen-pane XML). The function still produces the canonical 13-column workbook, but the doc comment no longer claims a behaviour that doesn't happen.
17 lines
No EOL
721 B
TypeScript
17 lines
No EOL
721 B
TypeScript
/**
|
|
* One-shot script: writes the canonical Plant_Hours_Template_2.xlsx
|
|
* to RAW_DOCS/. Run when the template layout changes — keep the
|
|
* seed file in sync with src/lib/plant-hours-template.ts.
|
|
*
|
|
* npx tsx scripts/generate-plant-hours-template.ts
|
|
*/
|
|
import * as fs from "node:fs";
|
|
import * as path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { buildPlantHoursTemplateWorkbook } from "../src/lib/plant-hours-template";
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
const out = path.resolve(here, "../RAW_DOCS/Plant_Hours_Template_2.xlsx");
|
|
const bytes = buildPlantHoursTemplateWorkbook();
|
|
fs.writeFileSync(out, bytes);
|
|
console.log(`Wrote ${out} (${bytes.byteLength} bytes)`); |