format with prettier
This commit is contained in:
parent
f7178d212a
commit
3c35c1e552
10 changed files with 540 additions and 466 deletions
|
|
@ -1,25 +1,26 @@
|
|||
// npx ts-node html-templates.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 { htmlTemplateX} from '../libs/html-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(pdf,png,jpeg): ');
|
||||
const ext =e?e:"pdf"
|
||||
const dpath = await rl.question('JSON data path(./html.json): ');
|
||||
const datapath = dpath?dpath:"./html.json"
|
||||
const data_raw = fs.readFileSync(datapath);
|
||||
const tdata:templateOption = JSON.parse(data_raw.toString());
|
||||
const bpath = await rl.question('templates path(../templates/html): ');
|
||||
const basepath = bpath?bpath:"../templates/html"
|
||||
// const template = await fs.promises.readFile(`${basepath}/${tdata.template}.docx`)
|
||||
let url = "https://bma-dashboard.frappet.synology.me/d/ANtkJay4z/4Lic4Li54LmJ4Lie4Li04LiB4Liy4Lij?orgId=1&kiosk"
|
||||
//let url = "https://pantip.com"
|
||||
// let url = "https://google.com"
|
||||
import * as readline from "node:readline/promises" // This uses the promise-based APIs
|
||||
import { stdin as input, stdout as output } from "node:process"
|
||||
import { htmlTemplateX } from "../libs/html-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(pdf,png,jpeg): ")
|
||||
const ext = e ? e : "pdf"
|
||||
const dpath = await rl.question("JSON data path(./html.json): ")
|
||||
const datapath = dpath ? dpath : "./html.json"
|
||||
const data_raw = fs.readFileSync(datapath)
|
||||
const tdata: templateOption = JSON.parse(data_raw.toString())
|
||||
const bpath = await rl.question("templates path(../templates/html): ")
|
||||
const basepath = bpath ? bpath : "../templates/html"
|
||||
// const template = await fs.promises.readFile(`${basepath}/${tdata.template}.docx`)
|
||||
let url =
|
||||
"https://bma-dashboard.frappet.synology.me/d/ANtkJay4z/4Lic4Li54LmJ4Lie4Li04LiB4Liy4Lij?orgId=1&kiosk"
|
||||
//let url = "https://pantip.com"
|
||||
// let url = "https://google.com"
|
||||
|
||||
let buffer = await htmlTemplateX(url, tdata,ext)
|
||||
fs.writeFileSync(".output/"+tdata.reportName+"."+ext, buffer);
|
||||
rl.close();
|
||||
})()
|
||||
let buffer = await htmlTemplateX(url, tdata, ext)
|
||||
fs.writeFileSync(".output/" + tdata.reportName + "." + ext, buffer)
|
||||
rl.close()
|
||||
})()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue