Convert to vite and clean up build
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
// Simple example to add text to a document
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
|
||||
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
|
@ -1,17 +1,7 @@
|
||||
// Example on how to customize the look at feel using Styles
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import {
|
||||
AlignmentType,
|
||||
convertInchesToTwip,
|
||||
Document,
|
||||
HeadingLevel,
|
||||
LevelFormat,
|
||||
Packer,
|
||||
Paragraph,
|
||||
TextRun,
|
||||
UnderlineType,
|
||||
} from "../build";
|
||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph, TextRun, UnderlineType } from "docx";
|
||||
|
||||
const doc = new Document({
|
||||
creator: "Clippy",
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
Tab,
|
||||
TextRun,
|
||||
VerticalPositionAlign,
|
||||
} from "../build";
|
||||
} from "docx";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Exporting the document as a stream
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, Tab, TextRun } from "../build";
|
||||
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
|
@ -1,21 +1,21 @@
|
||||
// Example of using tab stops
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "../build";
|
||||
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "docx";
|
||||
|
||||
const columnWidth = TabStopPosition.MAX / 4;
|
||||
const receiptTabStops = [
|
||||
// no need to define first left tab column
|
||||
// the right aligned tab column position should point to the end of column
|
||||
// i.e. in this case
|
||||
// (end position of 1st) + (end position of current)
|
||||
// columnWidth + columnWidth = columnWidth * 2
|
||||
// no need to define first left tab column
|
||||
// the right aligned tab column position should point to the end of column
|
||||
// i.e. in this case
|
||||
// (end position of 1st) + (end position of current)
|
||||
// columnWidth + columnWidth = columnWidth * 2
|
||||
|
||||
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
|
||||
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
|
||||
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX },
|
||||
],
|
||||
twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
|
||||
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
|
||||
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
|
||||
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX },
|
||||
];
|
||||
const twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
|
@ -1,14 +1,13 @@
|
||||
// tslint:disable:no-console
|
||||
/* eslint-disable no-console */
|
||||
import fs from "fs";
|
||||
import prompt from "prompt";
|
||||
// import shelljs from "shelljs";
|
||||
import prompt, { Schema } from "prompt";
|
||||
import { $ } from "execa";
|
||||
|
||||
console.log("What demo do you wish to run? (Enter a number)");
|
||||
|
||||
const schema = {
|
||||
const schema: Schema = {
|
||||
properties: {
|
||||
number: {
|
||||
demoNumber: {
|
||||
pattern: /^[0-9]+$/,
|
||||
message: "Please enter a number.",
|
||||
required: true,
|
||||
@ -18,8 +17,8 @@ const schema = {
|
||||
|
||||
prompt.start();
|
||||
|
||||
prompt.get(schema as any, async (_, result) => {
|
||||
const demoNumber = result.number as string;
|
||||
prompt.get(schema, async (_, result) => {
|
||||
const demoNumber = result.demoNumber as string;
|
||||
const files = fs.readdirSync("./demo").filter((fn) => fn.startsWith(demoNumber));
|
||||
|
||||
if (files.length === 0) {
|
||||
@ -30,12 +29,6 @@ prompt.get(schema as any, async (_, result) => {
|
||||
const filePath = `./demo/${files[0]}`;
|
||||
|
||||
console.log(`Running demo ${demoNumber}: ${files[0]}`);
|
||||
const { stdout } = await $`npm run ts-node -- ${filePath}`;
|
||||
console.log(stdout);
|
||||
|
||||
// if (shelljs.exec(`npm run ts-node -- ${filePath}`).code === 0) {
|
||||
// console.log("Document created successfully");
|
||||
// } else {
|
||||
// console.error("Something went wrong with the demo");
|
||||
// }
|
||||
await $`ts-node --project demo/tsconfig.json ${filePath}`;
|
||||
console.log("Successfully created document!");
|
||||
});
|
||||
|
10
demo/tsconfig.json
Normal file
10
demo/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./",
|
||||
"paths": {
|
||||
"docx": ["../build"]
|
||||
}
|
||||
},
|
||||
"include": ["../demo"]
|
||||
}
|
Reference in New Issue
Block a user