@magic-markdown/cli 0.3.8 → 0.3.10
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 +20 -5
- 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.10";
|
|
10994
11001
|
var CLI_PACKAGE_NAME = "@magic-markdown/cli";
|
|
10995
11002
|
var AGENT_COMMANDS = [
|
|
10996
11003
|
{
|
|
@@ -11667,6 +11674,7 @@ async function walk(root, output, base, rules, ignoreFiles) {
|
|
|
11667
11674
|
for (const entry of entries) {
|
|
11668
11675
|
const absolute = join2(root, entry.name);
|
|
11669
11676
|
const relativePath = relative(base, absolute).replaceAll("\\", "/");
|
|
11677
|
+
if (relativePath.endsWith(".tmp")) continue;
|
|
11670
11678
|
if (isIgnoredWorkspacePath(relativePath, rules)) continue;
|
|
11671
11679
|
if (ignoreMatcher(relativePath)) continue;
|
|
11672
11680
|
if (entry.isDirectory()) {
|
|
@@ -11676,11 +11684,18 @@ async function walk(root, output, base, rules, ignoreFiles) {
|
|
|
11676
11684
|
continue;
|
|
11677
11685
|
}
|
|
11678
11686
|
if (entry.isFile()) {
|
|
11679
|
-
const stats = await stat2(absolute)
|
|
11687
|
+
const stats = await stat2(absolute).catch((error) => {
|
|
11688
|
+
if (isMissingPathError(error)) return void 0;
|
|
11689
|
+
throw error;
|
|
11690
|
+
});
|
|
11691
|
+
if (!stats) continue;
|
|
11680
11692
|
if (isWorkspaceMarkdownPathAllowed(relativePath, rules, stats.size, ignoreMatcher)) output.push(normalizeWorkspacePath3(relativePath));
|
|
11681
11693
|
}
|
|
11682
11694
|
}
|
|
11683
11695
|
}
|
|
11696
|
+
function isMissingPathError(error) {
|
|
11697
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
11698
|
+
}
|
|
11684
11699
|
async function withDirectoryIgnoreFile(root, base, ignoreFiles) {
|
|
11685
11700
|
try {
|
|
11686
11701
|
const path = join2(relative(base, root).replaceAll("\\", "/"), ".gitignore").replace(/^\.\//, "");
|
package/package.json
CHANGED