mrvn-cli 0.2.9 → 0.3.0
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 +1061 -9
- package/dist/index.js.map +1 -1
- package/dist/marvin-serve.js +16 -3
- package/dist/marvin-serve.js.map +1 -1
- package/dist/marvin.js +1061 -9
- package/dist/marvin.js.map +1 -1
- package/package.json +1 -1
package/dist/marvin-serve.js
CHANGED
|
@@ -166,6 +166,11 @@ var DocumentStore = class {
|
|
|
166
166
|
const raw = fs3.readFileSync(filePath, "utf-8");
|
|
167
167
|
const doc = parseDocument(raw, filePath);
|
|
168
168
|
if (doc.frontmatter.id) {
|
|
169
|
+
if (this.index.has(doc.frontmatter.id)) {
|
|
170
|
+
console.warn(
|
|
171
|
+
`[marvin] Duplicate ID "${doc.frontmatter.id}" in ${file2} \u2014 conflicts with existing entry. Run ID repair to fix.`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
169
174
|
this.index.set(doc.frontmatter.id, doc.frontmatter);
|
|
170
175
|
}
|
|
171
176
|
}
|
|
@@ -286,14 +291,22 @@ var DocumentStore = class {
|
|
|
286
291
|
if (!prefix) {
|
|
287
292
|
throw new Error(`Unknown document type: ${type}`);
|
|
288
293
|
}
|
|
289
|
-
const
|
|
294
|
+
const dirName = this.typeDirs[type];
|
|
295
|
+
const dir = path3.join(this.docsDir, dirName);
|
|
296
|
+
if (!fs3.existsSync(dir)) return `${prefix}-001`;
|
|
297
|
+
const idPattern = new RegExp(`^${prefix}-(\\d+)$`);
|
|
298
|
+
const files = fs3.readdirSync(dir).filter((f) => f.endsWith(".md"));
|
|
290
299
|
let maxNum = 0;
|
|
291
|
-
for (const
|
|
292
|
-
const
|
|
300
|
+
for (const file2 of files) {
|
|
301
|
+
const filePath = path3.join(dir, file2);
|
|
302
|
+
const raw = fs3.readFileSync(filePath, "utf-8");
|
|
303
|
+
const doc = parseDocument(raw, filePath);
|
|
304
|
+
const match = doc.frontmatter.id?.match(idPattern);
|
|
293
305
|
if (match) {
|
|
294
306
|
maxNum = Math.max(maxNum, parseInt(match[1], 10));
|
|
295
307
|
}
|
|
296
308
|
}
|
|
309
|
+
maxNum = Math.max(maxNum, files.length);
|
|
297
310
|
return `${prefix}-${String(maxNum + 1).padStart(3, "0")}`;
|
|
298
311
|
}
|
|
299
312
|
counts() {
|