bun-docx 0.19.1 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +14 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -366,7 +366,7 @@ The CLI is built for non-interactive agents. **Exit code is the success signal**
|
|
|
366
366
|
| Command class | Default stdout on success | `--verbose` |
|
|
367
367
|
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
368
368
|
| **Mutator that mints a new handle** — `comments add`→`cN`, `comments reply`→`cN`, `footnotes/endnotes add`→`fnN`/`enN`, `hyperlinks add`→`linkN`, `insert`→the new `pN` | the bare locator(s), **one per line** (a multi-block `--markdown` insert prints several) | full `{ok:true,…}` ack |
|
|
369
|
-
| **Mutator with no new handle** — `edit`, `delete`, `replace`, `create`, `comments resolve/delete`, `images replace/delete`, `hyperlinks replace/delete`, `footnotes/endnotes edit/delete`, `headers/footers set/clear`, `tables *`, `track-changes accept/reject` & toggle | **one-line confirmation** — `<operation> <target>` (e.g. `edit t1:r0c1:p0`, `edit 7 changes`, `replace
|
|
369
|
+
| **Mutator with no new handle** — `edit`, `delete`, `replace`, `create`, `comments resolve/delete`, `images replace/delete`, `hyperlinks replace/delete`, `footnotes/endnotes edit/delete`, `headers/footers set/clear`, `tables *`, `track-changes accept/reject` & toggle | **one-line confirmation** — `<operation> <target>` (e.g. `edit t1:r0c1:p0`, `edit 7 changes`, `replace 3 occurrences replaced`) (exit `0`) | full `{ok:true,…}` ack |
|
|
370
370
|
| `find` | matched span locators, one per line (no matches → nothing, exit `0`) | `--json` → `{ totalMatches, query, view, matches:[…], normalizedQuery? }` |
|
|
371
371
|
| `wc` | the bare count (whole-doc adds a tab-separated `sections` column, like `wc`) | `--json` → `{ words, scope, view, sections? }` |
|
|
372
372
|
| `outline` | indented `LOCATOR⇥TEXT` tree (two spaces per level) | `--json` → nested `[{ id, locator, level, style, text, children }]` |
|
package/dist/index.js
CHANGED
|
@@ -93257,6 +93257,13 @@ async function runReplaceBatch(filePath, batchSource, values2) {
|
|
|
93257
93257
|
return EXIT2.OK;
|
|
93258
93258
|
}
|
|
93259
93259
|
await document4.save(outputPath);
|
|
93260
|
+
const noops = results.filter((entry) => entry.replaced === 0);
|
|
93261
|
+
if (noops.length > 0) {
|
|
93262
|
+
const list3 = noops.map((entry) => JSON.stringify(entry.pattern)).join(", ");
|
|
93263
|
+
const applied = results.length - noops.length;
|
|
93264
|
+
const savedNote = applied === 0 ? "No entry matched, so the document is unchanged." : `The other ${applied} ${applied === 1 ? "entry was" : "entries were"} applied and SAVED \u2014 this nonzero exit means "some entries missed," not "nothing changed."`;
|
|
93265
|
+
return await fail("MATCH_NOT_FOUND", `${noops.length} of ${results.length} replace ${results.length === 1 ? "entry" : "entries"} matched nothing (0 occurrences): ${list3}. ${savedNote}`, `Those patterns weren't found as LITERAL document text \u2014 check for read-view markup (\`<mark>\`/\`<u>\`) or a locator in the pattern. \`docx find\` locates the real text; --ignore-case/--regex/--at scope the search.`);
|
|
93266
|
+
}
|
|
93260
93267
|
await respondAck({
|
|
93261
93268
|
ok: true,
|
|
93262
93269
|
operation: "replace",
|
|
@@ -93459,22 +93466,8 @@ async function run40(args) {
|
|
|
93459
93466
|
return EXIT2.OK;
|
|
93460
93467
|
}
|
|
93461
93468
|
if (selected.length === 0) {
|
|
93462
|
-
|
|
93463
|
-
|
|
93464
|
-
operation: "replace",
|
|
93465
|
-
path: path2,
|
|
93466
|
-
pattern,
|
|
93467
|
-
replacement,
|
|
93468
|
-
regex: useRegex,
|
|
93469
|
-
ignoreCase,
|
|
93470
|
-
view: findView,
|
|
93471
|
-
...atScope ? { at: atScope } : {},
|
|
93472
|
-
totalMatches: 0,
|
|
93473
|
-
replaced: 0,
|
|
93474
|
-
matches: [],
|
|
93475
|
-
...normalizationFields
|
|
93476
|
-
});
|
|
93477
|
-
return EXIT2.OK;
|
|
93469
|
+
const scopeNote = atScope ? ` within ${atScope}` : "";
|
|
93470
|
+
return await fail("MATCH_NOT_FOUND", `Pattern not found${scopeNote}: ${JSON.stringify(pattern)} \u2014 0 occurrences, nothing changed.`, `Match LITERAL document text, not read-view markup (\`<mark>\`/\`<u>\`/\`**\`\u2026) or a locator. Run \`docx find ${JSON.stringify(pattern)} ${path2}\` to see if/where it occurs; add --ignore-case, --regex, --at <locator> to scope, or --current/--baseline to search tracked-change text.`);
|
|
93478
93471
|
}
|
|
93479
93472
|
const reversed = [...selected].sort((leftMatch, rightMatch) => {
|
|
93480
93473
|
if (leftMatch.blockId !== rightMatch.blockId) {
|
|
@@ -93580,6 +93573,10 @@ Output:
|
|
|
93580
93573
|
addressable handle (matched-span locators shift as text changes; re-read or
|
|
93581
93574
|
use --dry-run to see them). --verbose / --dry-run print
|
|
93582
93575
|
{ok:true, operation, totalMatches, replaced, matches:[{locator,\u2026}], \u2026}.
|
|
93576
|
+
A PATTERN that matches NOTHING is an error, not a silent success \u2014 0 occurrences
|
|
93577
|
+
exits nonzero (MATCH_NOT_FOUND), so a no-op replace can't read as "done." Unsure it
|
|
93578
|
+
matches? Probe with \`docx find PATTERN FILE\` or --dry-run and READ the reported count
|
|
93579
|
+
\u2014 both exit 0 whether or not it matches; only the real replace exits nonzero on 0.
|
|
93583
93580
|
Errors print {code, error, hint?} with a nonzero exit.
|
|
93584
93581
|
|
|
93585
93582
|
Examples:
|
|
@@ -98024,7 +98021,7 @@ Examples:
|
|
|
98024
98021
|
// package.json
|
|
98025
98022
|
var package_default = {
|
|
98026
98023
|
name: "bun-docx",
|
|
98027
|
-
version: "0.19.
|
|
98024
|
+
version: "0.19.2",
|
|
98028
98025
|
description: "Read, edit, redline, and comment on Microsoft Word .docx files from the command line \u2014 built for AI agents.",
|
|
98029
98026
|
keywords: [
|
|
98030
98027
|
"docx",
|