Skip to content

Commit

Permalink
Merge branch 'master' into patch-xmlns
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanmiu authored Oct 13, 2024
2 parents 5f6eaa2 + 368aa43 commit 47a6e17
Show file tree
Hide file tree
Showing 13 changed files with 3,455 additions and 2,767 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- uses: "./.github/actions/install-and-build"
- name: Archive Production Artifact
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: build
path: build
Expand All @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Test
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Lint
Expand All @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Prettier
Expand All @@ -62,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Prettier
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Demos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- uses: "./.github/actions/install-and-build"
- name: Run Demos
run: npm run run-ts -- ./demo/1-basic.ts
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Build 🔧
Expand All @@ -19,7 +19,7 @@ jobs:
echo "docx.js.org" > docs/.nojekyll
echo "docx.js.org" > docs/CNAME
- name: Archive Production Artifact
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: docs
path: docs
Expand All @@ -28,11 +28,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo 🛎️
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Download Artifact
uses: actions/download-artifact@master
uses: actions/download-artifact@v4
with:
name: docs
path: docs
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm ci
- run: npm run cspell
- run: npm run prettier
- run: npm run lint
- run: npm run test:ci

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm ci
- run: npm run build

publish-npm:
needs: [test, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
72 changes: 72 additions & 0 deletions demo/93-template-document.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Patch a document with patches

import * as fs from "fs";
import { patchDocument, PatchType, TextRun } from "docx";

patchDocument({
outputType: "nodebuffer",
data: fs.readFileSync("demo/assets/field-trip.docx"),
patches: {
todays_date: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: new Date().toLocaleDateString() })],
},

school_name: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

address: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "blah blah" })],
},

city: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

state: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

zip: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

phone: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

first_name: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

last_name: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

email_address: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

ft_dates: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},

grade: {
type: PatchType.PARAGRAPH,
children: [new TextRun({ text: "test" })],
},
},
}).then((doc) => {
fs.writeFileSync("My Document.docx", doc);
});
Binary file added demo/assets/field-trip.docx
Binary file not shown.
Loading

0 comments on commit 47a6e17

Please sign in to comment.