🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ooxml-tools/file

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ooxml-tools/file - npm Package Compare versions

Comparing version
0.1.1
to
0.1.2
+169
dist/npm/write-CHAwJQCt.js
import JSZip from 'jszip';
import { o as open, _ as __asyncValues } from './index-I5ZQQkwV.js';
import { mkdir, writeFile } from 'fs/promises';
import { join } from 'path';
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(docxpath);
const doc = open(zip);
console.log(doc.list());
}
var list = /*#__PURE__*/Object.freeze({
__proto__: null,
builder: builder$4,
cmd: cmd$4,
desc: desc$4,
handler: handler$4
});
const cmd$3 = "pack <docxpath> <filepath>";
const desc$3 = "pack directory to docx file";
const builder$3 = (yargs) => {
yargs
.positional("docxpath", {
type: "string",
describe: "",
})
.positional("filepath", {
type: "string",
describe: "",
});
};
async function handler$3({ filepath, dirpath }) {
new JSZip();
// TODO:
}
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(docxpath);
const doc = open(zip);
if (doc.list().includes(filepath)) {
process.exit(1);
}
else {
console.log(doc.readFile(filepath));
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(docxpath);
const doc = open(zip);
for (const docxpath of doc.list()) {
const outpath = join(docxpath, docxpath);
await mkdir(outpath, { recursive: true });
const data = await doc.readFile(docxpath);
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 data = Buffer.concat(buffers);
const zip = new JSZip();
await zip.loadAsync(docxpath);
const doc = open(zip);
await doc.writeFile(filepath, data);
}
var write = /*#__PURE__*/Object.freeze({
__proto__: null,
builder: builder,
cmd: cmd,
desc: desc,
handler: handler
});
export { cmd$1 as a, builder$3 as b, cmd$3 as c, desc$3 as d, desc$1 as e, builder$1 as f, handler$1 as g, handler$3 as h, cmd$4 as i, desc$4 as j, builder$4 as k, list as l, handler$4 as m, cmd$2 as n, desc$2 as o, pack as p, builder$2 as q, read as r, handler$2 as s, cmd as t, unpack as u, desc as v, write as w, builder as x, handler as y };
+1
-1
#!/usr/bin/env ./node_modules/.bin/tsx
import { relative } from 'path';
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, f as builder$1, g as handler$1, i as cmd$2, j as desc$2, k as builder$2, m as handler$2, n as cmd$3, o as desc$3, q as builder$3, s as handler$3, t as cmd$4, v as desc$4, x as builder$4, y as handler$4 } from '../write-pLaZQmpB.js';
import { c as cmd, d as desc, b as builder, h as handler, a as cmd$1, e as desc$1, f as builder$1, g as handler$1, i as cmd$2, j as desc$2, k as builder$2, m as handler$2, n as cmd$3, o as desc$3, q as builder$3, s as handler$3, t as cmd$4, v as desc$4, x as builder$4, y as handler$4 } from '../write-CHAwJQCt.js';
import 'jszip';

@@ -6,0 +6,0 @@ import '../index-I5ZQQkwV.js';

import { Argv, ArgumentsCamelCase } from 'yargs';
declare const cmd$4 = "list <docxpath> <filepath>";
declare const cmd$4 = "list <docxpath>";
declare const desc$4 = "list files in docx";

@@ -5,0 +5,0 @@ declare const builder$4: (yargs: Argv) => void;

@@ -1,2 +0,2 @@

export { l as list, p as pack, r as read, u as unpack, w as write } from './write-pLaZQmpB.js';
export { l as list, p as pack, r as read, u as unpack, w as write } from './write-CHAwJQCt.js';
import 'jszip';

@@ -3,0 +3,0 @@ import './index-I5ZQQkwV.js';

{
"name": "@ooxml-tools/file",
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "type": "module",

import JSZip from 'jszip';
import { o as open, _ as __asyncValues } from './index-I5ZQQkwV.js';
import { mkdir, writeFile } from 'fs/promises';
import { join } from 'path';
const cmd$4 = "list <docxpath> <filepath>";
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(docxpath);
const doc = open(zip);
console.log(doc.list());
}
var list = /*#__PURE__*/Object.freeze({
__proto__: null,
builder: builder$4,
cmd: cmd$4,
desc: desc$4,
handler: handler$4
});
const cmd$3 = "pack <docxpath> <filepath>";
const desc$3 = "pack directory to docx file";
const builder$3 = (yargs) => {
yargs
.positional("docxpath", {
type: "string",
describe: "",
})
.positional("filepath", {
type: "string",
describe: "",
});
};
async function handler$3({ filepath, dirpath }) {
new JSZip();
// TODO:
}
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(docxpath);
const doc = open(zip);
if (doc.list().includes(filepath)) {
process.exit(1);
}
else {
console.log(doc.readFile(filepath));
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(docxpath);
const doc = open(zip);
for (const docxpath of doc.list()) {
const outpath = join(docxpath, docxpath);
await mkdir(outpath, { recursive: true });
const data = await doc.readFile(docxpath);
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 data = Buffer.concat(buffers);
const zip = new JSZip();
await zip.loadAsync(docxpath);
const doc = open(zip);
await doc.writeFile(filepath, data);
}
var write = /*#__PURE__*/Object.freeze({
__proto__: null,
builder: builder,
cmd: cmd,
desc: desc,
handler: handler
});
export { cmd$1 as a, builder$3 as b, cmd$3 as c, desc$3 as d, desc$1 as e, builder$1 as f, handler$1 as g, handler$3 as h, cmd$4 as i, desc$4 as j, builder$4 as k, list as l, handler$4 as m, cmd$2 as n, desc$2 as o, pack as p, builder$2 as q, read as r, handler$2 as s, cmd as t, unpack as u, desc as v, write as w, builder as x, handler as y };