@magic-markdown/cli 0.3.8 → 0.3.9
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/dist/index.js +11 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1716,7 +1716,7 @@ async function readManifest(io) {
|
|
|
1716
1716
|
return JSON.parse(raw);
|
|
1717
1717
|
}
|
|
1718
1718
|
async function writeManifest(io, manifest) {
|
|
1719
|
-
await io
|
|
1719
|
+
await writeJsonText(io, MANIFEST_PATH, `${JSON.stringify(manifest, null, 2)}
|
|
1720
1720
|
`);
|
|
1721
1721
|
}
|
|
1722
1722
|
async function readSidecar(io, docId) {
|
|
@@ -1724,9 +1724,16 @@ async function readSidecar(io, docId) {
|
|
|
1724
1724
|
return JSON.parse(raw);
|
|
1725
1725
|
}
|
|
1726
1726
|
async function writeSidecar(io, sidecar) {
|
|
1727
|
-
await io
|
|
1727
|
+
await writeJsonText(io, sidecarPath(sidecar.docId), `${JSON.stringify(sidecar, null, 2)}
|
|
1728
1728
|
`);
|
|
1729
1729
|
}
|
|
1730
|
+
async function writeJsonText(io, path, content) {
|
|
1731
|
+
if (io.writeTextAtomic) {
|
|
1732
|
+
await io.writeTextAtomic(path, content);
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
await io.writeText(path, content);
|
|
1736
|
+
}
|
|
1730
1737
|
function findDoc(manifest, pathOrDocId) {
|
|
1731
1738
|
const entry = manifest.docs.find((doc) => doc.path === pathOrDocId || doc.docId === pathOrDocId);
|
|
1732
1739
|
if (!entry) throw new Error(`Unknown document: ${pathOrDocId}`);
|
|
@@ -1739,7 +1746,7 @@ async function readManifestIfPresent(io) {
|
|
|
1739
1746
|
async function ensureDocumentSidecar(io, entry, markdown) {
|
|
1740
1747
|
const path = sidecarPath(entry.docId);
|
|
1741
1748
|
if (await io.exists(path)) {
|
|
1742
|
-
const sidecar = await readSidecar(io, entry.docId);
|
|
1749
|
+
const sidecar = await readSidecar(io, entry.docId).catch(() => createEmptySidecar(entry));
|
|
1743
1750
|
await writeSidecar(io, {
|
|
1744
1751
|
...sidecar,
|
|
1745
1752
|
path: entry.path,
|
|
@@ -10990,7 +10997,7 @@ var RemoteDocumentIO = class {
|
|
|
10990
10997
|
};
|
|
10991
10998
|
|
|
10992
10999
|
// src/agent.ts
|
|
10993
|
-
var CLI_VERSION = "0.3.
|
|
11000
|
+
var CLI_VERSION = "0.3.9";
|
|
10994
11001
|
var CLI_PACKAGE_NAME = "@magic-markdown/cli";
|
|
10995
11002
|
var AGENT_COMMANDS = [
|
|
10996
11003
|
{
|
package/package.json
CHANGED