@ooxml-tools/file
Advanced tools
Sorry, the diff of this file is too big to display
| import { writeFile, stat, mkdir } from 'fs/promises'; | ||
| import JSZip from 'jszip'; | ||
| import { F as FORMATS, f as formatFromFilename, O as OfficeOpenXml, x as xlsxBlankFiles, d as docxBlankFiles, o as open, _ as __asyncValues } from './index-DvYx8smX.js'; | ||
| import { glob } from 'glob'; | ||
| import { relative, join, dirname } from 'path'; | ||
| import { openAsBlob } from 'fs'; | ||
| const blankContents = { | ||
| docx: docxBlankFiles, | ||
| xlsx: xlsxBlankFiles, | ||
| // pptx: pptxBlankFiles, | ||
| }; | ||
| const cmd$6 = "init <ooxmlpath>"; | ||
| const desc$6 = `initializes a blank file (${FORMATS.join(", ")})`; | ||
| const builder$6 = (yargs) => { | ||
| yargs.positional("ooxmlpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$6({ ooxmlpath, }) { | ||
| const zip = new JSZip(); | ||
| const format = formatFromFilename(ooxmlpath); | ||
| if (format !== "docx") { | ||
| throw new Error(`${format} not currently supported`); | ||
| } | ||
| const doc = new OfficeOpenXml(format, zip); | ||
| doc.writeFiles(blankContents[format]); | ||
| const buffer = await doc.pack("uint8array"); | ||
| await writeFile(ooxmlpath, buffer); | ||
| } | ||
| var init = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$6, | ||
| cmd: cmd$6, | ||
| desc: desc$6, | ||
| handler: handler$6 | ||
| }); | ||
| const cmd$5 = "formats"; | ||
| const desc$5 = `list valid formats`; | ||
| const builder$5 = (yargs) => { | ||
| }; | ||
| async function handler$5() { | ||
| console.log(FORMATS.join("\n")); | ||
| } | ||
| var formats = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$5, | ||
| cmd: cmd$5, | ||
| desc: desc$5, | ||
| handler: handler$5 | ||
| }); | ||
| async function openAsArrayBuffer(filepath) { | ||
| return await (await openAsBlob(filepath)).arrayBuffer(); | ||
| } | ||
| const cmd$4 = "list <filepath>"; | ||
| const desc$4 = "list files in docx"; | ||
| const builder$4 = (yargs) => { | ||
| yargs.positional("ooxmlpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$4({ ooxmlpath, }) { | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(await openAsArrayBuffer(ooxmlpath)); | ||
| const doc = open(formatFromFilename(ooxmlpath), zip); | ||
| console.log(doc.list().join("\n")); | ||
| } | ||
| var list = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$4, | ||
| cmd: cmd$4, | ||
| desc: desc$4, | ||
| handler: handler$4 | ||
| }); | ||
| const cmd$3 = "pack <filepath> <dirpath>"; | ||
| const desc$3 = "pack directory to docx file"; | ||
| const builder$3 = (yargs) => { | ||
| yargs | ||
| .positional("ooxmlpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("dirpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$3({ ooxmlpath, dirpath, }) { | ||
| const zip = new JSZip(); | ||
| const doc = open(formatFromFilename(ooxmlpath), zip); | ||
| const files = await glob(`${dirpath}/**/*`, { | ||
| ignore: "**/.DS_Store", | ||
| dot: true, | ||
| }); | ||
| for (const localFilepath of files) { | ||
| const filepath = relative(dirpath, localFilepath); | ||
| const isFile = (await stat(localFilepath)).isFile(); | ||
| if (isFile) { | ||
| doc.writeFile(filepath, await openAsArrayBuffer(localFilepath)); | ||
| } | ||
| } | ||
| const buffer = await doc.pack("uint8array"); | ||
| await writeFile(ooxmlpath, buffer); | ||
| } | ||
| var pack = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$3, | ||
| cmd: cmd$3, | ||
| desc: desc$3, | ||
| handler: handler$3 | ||
| }); | ||
| const cmd$2 = "read <ooxmlpath> <filepath>"; | ||
| const desc$2 = "read file inside docx to sdtout"; | ||
| const builder$2 = (yargs) => { | ||
| yargs | ||
| .positional("ooxmlpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("filepath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$2({ ooxmlpath, filepath, }) { | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(openAsArrayBuffer(ooxmlpath)); | ||
| const doc = open(formatFromFilename(ooxmlpath), zip); | ||
| if (!doc.list().includes(filepath)) { | ||
| console.error(`Missing file: ${filepath}`); | ||
| process.exit(1); | ||
| } | ||
| else { | ||
| const content = await doc.readFile(filepath, "uint8array"); | ||
| const stringContent = new TextDecoder().decode(content); | ||
| console.log(stringContent); | ||
| process.exit(0); | ||
| } | ||
| } | ||
| var read = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$2, | ||
| cmd: cmd$2, | ||
| desc: desc$2, | ||
| handler: handler$2 | ||
| }); | ||
| const cmd$1 = "unpack <ooxmlpath> <dirpath>"; | ||
| const desc$1 = "unpack docx to a directory"; | ||
| const builder$1 = (yargs) => { | ||
| yargs | ||
| .positional("ooxmlpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("dirpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$1({ ooxmlpath, dirpath, }) { | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(openAsArrayBuffer(ooxmlpath)); | ||
| const doc = open(formatFromFilename(ooxmlpath), zip); | ||
| for (const ooxmlpath of doc.list()) { | ||
| if (doc.isDirectory(ooxmlpath)) { | ||
| await mkdir(ooxmlpath, { recursive: true }); | ||
| } | ||
| else { | ||
| const outpath = join(dirpath, ooxmlpath); | ||
| await mkdir(dirname(outpath), { recursive: true }); | ||
| const data = await doc.readFile(ooxmlpath, "uint8array"); | ||
| await writeFile(outpath, data); | ||
| } | ||
| } | ||
| } | ||
| var unpack = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$1, | ||
| cmd: cmd$1, | ||
| desc: desc$1, | ||
| handler: handler$1 | ||
| }); | ||
| const cmd = "write <ooxmlpath> <filepath>"; | ||
| const desc = "create/override file in docx"; | ||
| const builder = (yargs) => { | ||
| yargs | ||
| .positional("ooxmlpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("filepath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler({ ooxmlpath, filepath, }) { | ||
| var _a, e_1, _b, _c; | ||
| const buffers = []; | ||
| try { | ||
| for (var _d = true, _e = __asyncValues(process.stdin), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) { | ||
| _c = _f.value; | ||
| _d = false; | ||
| const data = _c; | ||
| buffers.push(data); | ||
| } | ||
| } | ||
| catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
| finally { | ||
| try { | ||
| if (!_d && !_a && (_b = _e.return)) await _b.call(_e); | ||
| } | ||
| finally { if (e_1) throw e_1.error; } | ||
| } | ||
| const inputData = new Blob([Buffer.concat(buffers)]); | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(openAsArrayBuffer(ooxmlpath)); | ||
| const doc = open(formatFromFilename(ooxmlpath), zip); | ||
| doc.writeFile(filepath, await inputData.arrayBuffer()); | ||
| const buffer = await doc.pack("uint8array"); | ||
| await writeFile(ooxmlpath, buffer); | ||
| } | ||
| var write = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder, | ||
| cmd: cmd, | ||
| desc: desc, | ||
| handler: handler | ||
| }); | ||
| export { handler$4 as A, cmd$2 as B, desc$2 as C, builder$2 as D, handler$2 as E, cmd as F, desc as G, builder as H, handler as I, cmd$6 as a, builder$5 as b, cmd$5 as c, desc$5 as d, desc$6 as e, formats as f, builder$6 as g, handler$5 as h, init as i, handler$6 as j, cmd$3 as k, list as l, desc$3 as m, builder$3 as n, handler$3 as o, pack as p, cmd$1 as q, read as r, desc$1 as s, builder$1 as t, unpack as u, handler$1 as v, write as w, cmd$4 as x, desc$4 as y, builder$4 as z }; |
| #!/usr/bin/env node | ||
| import yargs from 'yargs/yargs'; | ||
| import { c as cmd, d as desc, b as builder, h as handler, a as cmd$1, e as desc$1, g as builder$1, j as handler$1, k as cmd$2, m as desc$2, n as builder$2, o as handler$2, q as cmd$3, s as desc$3, t as builder$3, v as handler$3, x as cmd$4, y as desc$4, z as builder$4, A as handler$4, B as cmd$5, C as desc$5, D as builder$5, E as handler$5, F as cmd$6, G as desc$6, H as builder$6, I as handler$6 } from '../write-Cjfn_G9H.js'; | ||
| import { c as cmd, d as desc, b as builder, h as handler, a as cmd$1, e as desc$1, g as builder$1, j as handler$1, k as cmd$2, m as desc$2, n as builder$2, o as handler$2, q as cmd$3, s as desc$3, t as builder$3, v as handler$3, x as cmd$4, y as desc$4, z as builder$4, A as handler$4, B as cmd$5, C as desc$5, D as builder$5, E as handler$5, F as cmd$6, G as desc$6, H as builder$6, I as handler$6 } from '../write-ejPQ5tHk.js'; | ||
| import 'fs/promises'; | ||
| import 'jszip'; | ||
| import '../index-ClYnXEp7.js'; | ||
| import '../index-DvYx8smX.js'; | ||
| import 'path'; | ||
@@ -11,3 +11,3 @@ import 'glob'; | ||
| var version = "0.4.0"; | ||
| var version = "0.5.0"; | ||
@@ -14,0 +14,0 @@ const scriptName = "ooxml-file"; |
+18
-18
| import { Argv, ArgumentsCamelCase } from 'yargs'; | ||
| declare const cmd$6 = "init <docxpath>"; | ||
| declare const cmd$6 = "init <ooxmlpath>"; | ||
| declare const desc$6: string; | ||
| declare const builder$6: (yargs: Argv) => void; | ||
| declare function handler$6({ docxpath, }: ArgumentsCamelCase<{ | ||
| docxpath: string; | ||
| declare function handler$6({ ooxmlpath, }: ArgumentsCamelCase<{ | ||
| ooxmlpath: string; | ||
| }>): Promise<void>; | ||
@@ -33,7 +33,7 @@ | ||
| declare const cmd$4 = "list <docxpath>"; | ||
| declare const cmd$4 = "list <filepath>"; | ||
| declare const desc$4 = "list files in docx"; | ||
| declare const builder$4: (yargs: Argv) => void; | ||
| declare function handler$4({ docxpath, }: ArgumentsCamelCase<{ | ||
| docxpath: string; | ||
| declare function handler$4({ ooxmlpath, }: ArgumentsCamelCase<{ | ||
| ooxmlpath: string; | ||
| }>): Promise<void>; | ||
@@ -50,7 +50,7 @@ | ||
| declare const cmd$3 = "pack <docxpath> <dirpath>"; | ||
| declare const cmd$3 = "pack <filepath> <dirpath>"; | ||
| declare const desc$3 = "pack directory to docx file"; | ||
| declare const builder$3: (yargs: Argv) => void; | ||
| declare function handler$3({ docxpath, dirpath, }: ArgumentsCamelCase<{ | ||
| docxpath: string; | ||
| declare function handler$3({ ooxmlpath, dirpath, }: ArgumentsCamelCase<{ | ||
| ooxmlpath: string; | ||
| dirpath: string; | ||
@@ -68,7 +68,7 @@ }>): Promise<void>; | ||
| declare const cmd$2 = "read <docxpath> <filepath>"; | ||
| declare const cmd$2 = "read <ooxmlpath> <filepath>"; | ||
| declare const desc$2 = "read file inside docx to sdtout"; | ||
| declare const builder$2: (yargs: Argv) => void; | ||
| declare function handler$2({ docxpath, filepath, }: ArgumentsCamelCase<{ | ||
| docxpath: string; | ||
| declare function handler$2({ ooxmlpath, filepath, }: ArgumentsCamelCase<{ | ||
| ooxmlpath: string; | ||
| filepath: string; | ||
@@ -86,7 +86,7 @@ }>): Promise<void>; | ||
| declare const cmd$1 = "unpack <docxpath> <dirpath>"; | ||
| declare const cmd$1 = "unpack <ooxmlpath> <dirpath>"; | ||
| declare const desc$1 = "unpack docx to a directory"; | ||
| declare const builder$1: (yargs: Argv) => void; | ||
| declare function handler$1({ docxpath, dirpath, }: ArgumentsCamelCase<{ | ||
| docxpath: string; | ||
| declare function handler$1({ ooxmlpath, dirpath, }: ArgumentsCamelCase<{ | ||
| ooxmlpath: string; | ||
| dirpath: string; | ||
@@ -104,7 +104,7 @@ }>): Promise<void>; | ||
| declare const cmd = "write <docxpath> <filepath>"; | ||
| declare const cmd = "write <ooxmlpath> <filepath>"; | ||
| declare const desc = "create/override file in docx"; | ||
| declare const builder: (yargs: Argv) => void; | ||
| declare function handler({ docxpath, filepath, }: ArgumentsCamelCase<{ | ||
| docxpath: string; | ||
| declare function handler({ ooxmlpath, filepath, }: ArgumentsCamelCase<{ | ||
| ooxmlpath: string; | ||
| filepath: string; | ||
@@ -111,0 +111,0 @@ }>): Promise<void>; |
@@ -1,7 +0,7 @@ | ||
| export { f as formats, i as init, l as list, p as pack, r as read, u as unpack, w as write } from './write-Cjfn_G9H.js'; | ||
| export { f as formats, i as init, l as list, p as pack, r as read, u as unpack, w as write } from './write-ejPQ5tHk.js'; | ||
| import 'fs/promises'; | ||
| import 'jszip'; | ||
| import './index-ClYnXEp7.js'; | ||
| import './index-DvYx8smX.js'; | ||
| import 'path'; | ||
| import 'glob'; | ||
| import 'fs'; |
@@ -1,3 +0,3 @@ | ||
| export { F as FORMATS, M as MIME_TYPES, O as OfficeOpenXml, a as assertValidType, d as docxBlankFiles, f as formatFromFilename, g as getMimeType, i as init, o as open, p as pptxBlankFiles, x as xlsxBlankFiles } from './index-ClYnXEp7.js'; | ||
| export { F as FORMATS, M as MIME_TYPES, O as OfficeOpenXml, a as assertValidType, d as docxBlankFiles, f as formatFromFilename, g as getMimeType, i as init, o as open, p as pptxBlankFiles, x as xlsxBlankFiles } from './index-DvYx8smX.js'; | ||
| import 'jszip'; | ||
| import 'path'; |
+6
-2
| { | ||
| "name": "@ooxml-tools/file", | ||
| "description": "Read/write Office Open XML files in nodejs/browser", | ||
| "version": "0.4.0", | ||
| "version": "0.5.0", | ||
| "license": "MIT", | ||
@@ -21,2 +21,6 @@ "main": "./dist/npm/index.js", | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/ooxml-tools/file" | ||
| }, | ||
| "exports": { | ||
@@ -39,3 +43,3 @@ ".": "./dist/npm/index.js", | ||
| "@vitest/coverage-v8": "^4.0.15", | ||
| "prettier": "3.7.4", | ||
| "prettier": "^3.8.1", | ||
| "rollup": "^4.18.1", | ||
@@ -42,0 +46,0 @@ "rollup-plugin-copy": "^3.5.0", |
+8
-8
@@ -14,3 +14,3 @@ <h1> | ||
| - ✅ `.docx` — [WordprocessingML](http://officeopenxml.com/anatomyofOOXML.php) | ||
| - ✅ `.xlsx` — [SpreadsheetML](http://officeopenxml.com/anatomyofOOXML-xlsx.php) (coming soon) | ||
| - ✅ `.xlsx` — [SpreadsheetML](http://officeopenxml.com/anatomyofOOXML-xlsx.php) | ||
| - 👷 `.pptx` — [PresentationML](http://officeopenxml.com/anatomyofOOXML-pptx.php) (coming soon) | ||
@@ -25,3 +25,3 @@ | ||
| await zip.loadAsync(openAsArrayBuffer(docxpath)); | ||
| await zip.loadAsync(openAsArrayBuffer(ooxmlpath)); | ||
| const doc = open("docx", zip); | ||
@@ -38,8 +38,8 @@ console.log(await docx.list()); | ||
| # formats list valid formats | ||
| # init <docxpath> initializes a blank file (docx) | ||
| # pack <docxpath> <dirpath> pack directory to docx file | ||
| # unpack <docxpath> <dirpath> unpack docx to a directory | ||
| # list <docxpath> list files in docx | ||
| # read <docxpath> <filepath> read file inside docx to sdtout | ||
| # write <docxpath> <filepath> create/override file in docx | ||
| # init <ooxmlpath> initializes a blank file (docx) | ||
| # pack <ooxmlpath> <dirpath> pack directory to docx file | ||
| # unpack <ooxmlpath> <dirpath> unpack docx to a directory | ||
| # list <ooxmlpath> list files in docx | ||
| # read <ooxmlpath> <filepath> read file inside docx to sdtout | ||
| # write <ooxmlpath> <filepath> create/override file in docx | ||
| # | ||
@@ -46,0 +46,0 @@ # Options: |
Sorry, the diff of this file is too big to display
| import { writeFile, stat, mkdir } from 'fs/promises'; | ||
| import JSZip from 'jszip'; | ||
| import { F as FORMATS, f as formatFromFilename, O as OfficeOpenXml, d as docxBlankFiles, o as open, _ as __asyncValues } from './index-ClYnXEp7.js'; | ||
| import { glob } from 'glob'; | ||
| import { relative, join, dirname } from 'path'; | ||
| import { openAsBlob } from 'fs'; | ||
| const blankContents = { | ||
| docx: docxBlankFiles, | ||
| // xlsx: xlsxBlankFiles, | ||
| // pptx: pptxBlankFiles, | ||
| }; | ||
| const cmd$6 = "init <docxpath>"; | ||
| const desc$6 = `initializes a blank file (${FORMATS.join(", ")})`; | ||
| const builder$6 = (yargs) => { | ||
| yargs.positional("docxpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$6({ docxpath, }) { | ||
| const zip = new JSZip(); | ||
| const format = formatFromFilename(docxpath); | ||
| if (format !== "docx") { | ||
| throw new Error(`${format} not currently supported`); | ||
| } | ||
| const doc = new OfficeOpenXml(format, zip); | ||
| doc.writeFiles(blankContents[format]); | ||
| const buffer = await doc.pack("uint8array"); | ||
| await writeFile(docxpath, buffer); | ||
| } | ||
| var init = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$6, | ||
| cmd: cmd$6, | ||
| desc: desc$6, | ||
| handler: handler$6 | ||
| }); | ||
| const cmd$5 = "formats"; | ||
| const desc$5 = `list valid formats`; | ||
| const builder$5 = (yargs) => { | ||
| }; | ||
| async function handler$5() { | ||
| console.log(FORMATS.join("\n")); | ||
| } | ||
| var formats = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$5, | ||
| cmd: cmd$5, | ||
| desc: desc$5, | ||
| handler: handler$5 | ||
| }); | ||
| async function openAsArrayBuffer(filepath) { | ||
| return await (await openAsBlob(filepath)).arrayBuffer(); | ||
| } | ||
| const cmd$4 = "list <docxpath>"; | ||
| const desc$4 = "list files in docx"; | ||
| const builder$4 = (yargs) => { | ||
| yargs.positional("docxpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$4({ docxpath, }) { | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(await openAsArrayBuffer(docxpath)); | ||
| const doc = open(formatFromFilename(docxpath), zip); | ||
| console.log(doc.list().join("\n")); | ||
| } | ||
| var list = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$4, | ||
| cmd: cmd$4, | ||
| desc: desc$4, | ||
| handler: handler$4 | ||
| }); | ||
| const cmd$3 = "pack <docxpath> <dirpath>"; | ||
| const desc$3 = "pack directory to docx file"; | ||
| const builder$3 = (yargs) => { | ||
| yargs | ||
| .positional("docxpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("dirpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$3({ docxpath, dirpath, }) { | ||
| const zip = new JSZip(); | ||
| const doc = open(formatFromFilename(docxpath), zip); | ||
| const files = await glob(`${dirpath}/**/*`, { | ||
| ignore: "**/.DS_Store", | ||
| dot: true, | ||
| }); | ||
| for (const localFilepath of files) { | ||
| const filepath = relative(dirpath, localFilepath); | ||
| const isFile = (await stat(localFilepath)).isFile(); | ||
| if (isFile) { | ||
| doc.writeFile(filepath, await openAsArrayBuffer(localFilepath)); | ||
| } | ||
| } | ||
| const buffer = await doc.pack("uint8array"); | ||
| await writeFile(docxpath, buffer); | ||
| } | ||
| var pack = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$3, | ||
| cmd: cmd$3, | ||
| desc: desc$3, | ||
| handler: handler$3 | ||
| }); | ||
| const cmd$2 = "read <docxpath> <filepath>"; | ||
| const desc$2 = "read file inside docx to sdtout"; | ||
| const builder$2 = (yargs) => { | ||
| yargs | ||
| .positional("docxpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("filepath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$2({ docxpath, filepath, }) { | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(openAsArrayBuffer(docxpath)); | ||
| const doc = open(formatFromFilename(docxpath), zip); | ||
| if (!doc.list().includes(filepath)) { | ||
| console.error(`Missing file: ${filepath}`); | ||
| process.exit(1); | ||
| } | ||
| else { | ||
| const content = await doc.readFile(filepath, "uint8array"); | ||
| const stringContent = new TextDecoder().decode(content); | ||
| console.log(stringContent); | ||
| process.exit(0); | ||
| } | ||
| } | ||
| var read = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$2, | ||
| cmd: cmd$2, | ||
| desc: desc$2, | ||
| handler: handler$2 | ||
| }); | ||
| const cmd$1 = "unpack <docxpath> <dirpath>"; | ||
| const desc$1 = "unpack docx to a directory"; | ||
| const builder$1 = (yargs) => { | ||
| yargs | ||
| .positional("docxpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("dirpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler$1({ docxpath, dirpath, }) { | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(openAsArrayBuffer(docxpath)); | ||
| const doc = open(formatFromFilename(docxpath), zip); | ||
| for (const docxpath of doc.list()) { | ||
| if (doc.isDirectory(docxpath)) { | ||
| await mkdir(docxpath, { recursive: true }); | ||
| } | ||
| else { | ||
| const outpath = join(dirpath, docxpath); | ||
| await mkdir(dirname(outpath), { recursive: true }); | ||
| const data = await doc.readFile(docxpath, "uint8array"); | ||
| await writeFile(outpath, data); | ||
| } | ||
| } | ||
| } | ||
| var unpack = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder$1, | ||
| cmd: cmd$1, | ||
| desc: desc$1, | ||
| handler: handler$1 | ||
| }); | ||
| const cmd = "write <docxpath> <filepath>"; | ||
| const desc = "create/override file in docx"; | ||
| const builder = (yargs) => { | ||
| yargs | ||
| .positional("docxpath", { | ||
| type: "string", | ||
| describe: "", | ||
| }) | ||
| .positional("filepath", { | ||
| type: "string", | ||
| describe: "", | ||
| }); | ||
| }; | ||
| async function handler({ docxpath, filepath, }) { | ||
| var _a, e_1, _b, _c; | ||
| const buffers = []; | ||
| try { | ||
| for (var _d = true, _e = __asyncValues(process.stdin), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) { | ||
| _c = _f.value; | ||
| _d = false; | ||
| const data = _c; | ||
| buffers.push(data); | ||
| } | ||
| } | ||
| catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
| finally { | ||
| try { | ||
| if (!_d && !_a && (_b = _e.return)) await _b.call(_e); | ||
| } | ||
| finally { if (e_1) throw e_1.error; } | ||
| } | ||
| const inputData = new Blob([Buffer.concat(buffers)]); | ||
| const zip = new JSZip(); | ||
| await zip.loadAsync(openAsArrayBuffer(docxpath)); | ||
| const doc = open(formatFromFilename(docxpath), zip); | ||
| doc.writeFile(filepath, await inputData.arrayBuffer()); | ||
| const buffer = await doc.pack("uint8array"); | ||
| await writeFile(docxpath, buffer); | ||
| } | ||
| var write = /*#__PURE__*/Object.freeze({ | ||
| __proto__: null, | ||
| builder: builder, | ||
| cmd: cmd, | ||
| desc: desc, | ||
| handler: handler | ||
| }); | ||
| export { handler$4 as A, cmd$2 as B, desc$2 as C, builder$2 as D, handler$2 as E, cmd as F, desc as G, builder as H, handler as I, cmd$6 as a, builder$5 as b, cmd$5 as c, desc$5 as d, desc$6 as e, formats as f, builder$6 as g, handler$5 as h, init as i, handler$6 as j, cmd$3 as k, list as l, desc$3 as m, builder$3 as n, handler$3 as o, pack as p, cmd$1 as q, read as r, desc$1 as s, builder$1 as t, unpack as u, handler$1 as v, write as w, cmd$4 as x, desc$4 as y, builder$4 as z }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
229366
0.08%35
-2.78%