diff --git a/ts/export/formatter.ts b/ts/export/formatter.ts index d8a79b8e9c..163e059148 100644 --- a/ts/export/formatter.ts +++ b/ts/export/formatter.ts @@ -3,10 +3,10 @@ import {XmlComponent} from "../docx/xml-components"; export class Formatter { - format(input: any): Object { + public format(input: any): Object { input.clearVariables(); this.replaceKeys(input); - let newJson = this.clense(input); + const newJson = this.clense(input); // console.log(JSON.stringify(newJson, null, " ")); return newJson; } @@ -18,7 +18,7 @@ export class Formatter { } private clense(input: any): Object { - let newJson = this.jsonify(input); + const newJson = this.jsonify(input); this.deepTraverseJson(newJson, (parent, value, key) => { if (key === "properties") { diff --git a/ts/export/index.ts b/ts/export/index.ts index 038e23af47..2c4a25509a 100644 --- a/ts/export/index.ts +++ b/ts/export/index.ts @@ -1,2 +1,2 @@ -export {LocalPacker} from "./packer/local"; -export {ExpressPacker} from "./packer/express"; \ No newline at end of file +export { LocalPacker } from "./packer/local"; +export { ExpressPacker } from "./packer/express"; \ No newline at end of file diff --git a/ts/export/packer/express.ts b/ts/export/packer/express.ts index d491043292..e7dad5dc08 100644 --- a/ts/export/packer/express.ts +++ b/ts/export/packer/express.ts @@ -1,9 +1,10 @@ -import {Packer} from "./packer"; -import * as fs from "fs"; import * as express from "express"; -import {Document} from "../../docx/document"; -import {Properties} from "../../properties"; -import {Numbering} from "../../numbering"; +import * as fs from "fs"; +import { Document } from "../../docx/document"; +import { Numbering } from "../../numbering"; +import { Properties } from "../../properties"; +import { Packer } from "./packer"; + export class ExpressPacker extends Packer { private res: express.Response; @@ -17,8 +18,8 @@ export class ExpressPacker extends Packer { }); } - pack(name: string): void { + public pack(name: string): void { this.res.attachment(name + ".docx"); super.pack(this.res); } -} \ No newline at end of file +} diff --git a/ts/export/packer/local.ts b/ts/export/packer/local.ts index 63d13179da..6ce796096e 100644 --- a/ts/export/packer/local.ts +++ b/ts/export/packer/local.ts @@ -1,8 +1,9 @@ -import {Packer} from "./packer"; import * as fs from "fs"; -import {Document} from "../../docx/document"; -import {Properties} from "../../properties"; -import {Numbering} from "../../numbering"; +import { Document } from "../../docx/document"; +import { Numbering } from "../../numbering"; +import { Properties } from "../../properties"; +import { Packer } from "./packer"; + export class LocalPacker extends Packer { private stream: fs.WriteStream; @@ -11,8 +12,8 @@ export class LocalPacker extends Packer { super(document, styles, properties, numbering); } - pack(path: string): void { + public pack(path: string): void { this.stream = fs.createWriteStream(path); super.pack(this.stream); } -} \ No newline at end of file +} diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts index 8d19918ec9..90d32584ca 100644 --- a/ts/export/packer/packer.ts +++ b/ts/export/packer/packer.ts @@ -1,19 +1,19 @@ import * as archiver from "archiver"; import * as fs from "fs"; import * as xml from "xml"; -import {Formatter} from "../formatter"; -import {Document} from "../../docx"; -import {Styles} from "../../styles"; -import {Properties} from "../../properties"; -import {Numbering} from "../../numbering"; -import {DefaultStylesFactory} from "../../styles/factory"; +import { Document } from "../../docx"; +import { Numbering } from "../../numbering"; +import { Properties } from "../../properties"; +import { Styles } from "../../styles"; +import { DefaultStylesFactory } from "../../styles/factory"; +import { Formatter } from "../formatter"; -let appRoot = require("app-root-path"); +const appRoot = require("app-root-path"); export abstract class Packer { protected archive: any; - private formatter: Formatter; protected document: Document; + private formatter: Formatter; private style: Styles; private properties: Properties; private numbering: Numbering; @@ -27,7 +27,7 @@ export abstract class Packer { this.archive = archiver.create("zip", {}); if (!style) { - let stylesFactory = new DefaultStylesFactory(); + const stylesFactory = new DefaultStylesFactory(); this.style = stylesFactory.newInstance(); } @@ -35,7 +35,7 @@ export abstract class Packer { this.properties = new Properties({ creator: "Un-named", revision: "1", - lastModifiedBy: "Un-named" + lastModifiedBy: "Un-named", }); } @@ -48,7 +48,7 @@ export abstract class Packer { }); } - pack(output: any): void { + public pack(output: any): void { this.archive.pipe(output); console.log(appRoot.path + "/template"); this.archive.glob("**", { @@ -69,28 +69,28 @@ export abstract class Packer { name: "/root/g.txt", prefix: "root" });*/ - let xmlDocument = xml(this.formatter.format(this.document)); - let xmlStyles = xml(this.formatter.format(this.style)); - let xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: "yes", encoding: "UTF-8" } }); - let xmlNumbering = xml(this.formatter.format(this.numbering)); + const xmlDocument = xml(this.formatter.format(this.document)); + const xmlStyles = xml(this.formatter.format(this.style)); + const xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: "yes", encoding: "UTF-8" } }); + const xmlNumbering = xml(this.formatter.format(this.numbering)); // console.log(JSON.stringify(this.numbering, null, " ")); console.log(xmlNumbering); this.archive.append(xmlDocument, { - name: "word/document.xml" + name: "word/document.xml", }); this.archive.append(xmlStyles, { - name: "word/styles.xml" + name: "word/styles.xml", }); this.archive.append(xmlProperties, { - name: "docProps/core.xml" + name: "docProps/core.xml", }); this.archive.append(xmlNumbering, { - name: "word/numbering.xml" + name: "word/numbering.xml", }); this.archive.finalize(); } -} \ No newline at end of file +}