format with prettier

This commit is contained in:
oom 2025-02-28 11:43:17 +07:00
parent f7178d212a
commit 3c35c1e552
10 changed files with 540 additions and 466 deletions

View file

@ -1,22 +1,25 @@
// npx ts-node docx-template.ts
import * as readline from 'node:readline/promises'; // This uses the promise-based APIs
import { stdin as input, stdout as output } from 'node:process';
import { docxTemplateX} from '../libs/docx-templates-lib';
import {templateOption} from '../libs/report-template'
import fs from 'fs';
(async ()=>{
const rl = readline.createInterface({ input, output });
const e = await rl.question('Output extension(docx,pdf,odt,png,jpeg): ');
const ext =e?e:"docx"
const dpath = await rl.question('JSON data path(./docx.json): ');
const datapath = dpath?dpath:"./docx.json"
const data_raw = fs.readFileSync(datapath);
const tdata:templateOption = JSON.parse(data_raw.toString());
const bpath = await rl.question('templates path(../templates/docx): ');
const basepath = bpath?bpath:"../templates/docx"
//const template = await fs.promises.readFile(`${basepath}/${tdata.template}.docx`)
let buffer = await docxTemplateX(`${basepath}/${tdata.template}.docx`, tdata,ext)
fs.writeFileSync(".output/"+tdata.reportName+"."+ext, buffer);
rl.close();
import * as readline from "node:readline/promises" // This uses the promise-based APIs
import { stdin as input, stdout as output } from "node:process"
import { docxTemplateX } from "../libs/docx-templates-lib"
import { templateOption } from "../libs/report-template"
import fs from "fs"
(async () => {
const rl = readline.createInterface({ input, output })
const e = await rl.question("Output extension(docx,pdf,odt,png,jpeg): ")
const ext = e ? e : "docx"
const dpath = await rl.question("JSON data path(./docx.json): ")
const datapath = dpath ? dpath : "./docx.json"
const data_raw = fs.readFileSync(datapath)
const tdata: templateOption = JSON.parse(data_raw.toString())
const bpath = await rl.question("templates path(../templates/docx): ")
const basepath = bpath ? bpath : "../templates/docx"
//const template = await fs.promises.readFile(`${basepath}/${tdata.template}.docx`)
let buffer = await docxTemplateX(
`${basepath}/${tdata.template}.docx`,
tdata,
ext
)
fs.writeFileSync(".output/" + tdata.reportName + "." + ext, buffer)
rl.close()
})()