@thallylabs/migrate 0.2.3 → 0.2.4
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 +21 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -534,15 +534,26 @@ function projectDocusaurusNavigation(input) {
|
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
// src/frontmatter.ts
|
|
537
|
-
import
|
|
538
|
-
var FRONTMATTER_OPTIONS = {
|
|
539
|
-
engines: {
|
|
540
|
-
javascript: () => ({}),
|
|
541
|
-
js: () => ({})
|
|
542
|
-
}
|
|
543
|
-
};
|
|
537
|
+
import { parse as parseYaml2 } from "yaml";
|
|
544
538
|
function parseFrontmatter(raw) {
|
|
545
|
-
|
|
539
|
+
const source = raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw;
|
|
540
|
+
const opening = /^---([^\r\n]*)\r?\n/.exec(source);
|
|
541
|
+
if (!opening || opening[1].startsWith("-")) return { content: source, data: {} };
|
|
542
|
+
const language = opening[1].trim().toLowerCase();
|
|
543
|
+
const remainder = source.slice(opening[0].length);
|
|
544
|
+
const closing = /^---[ \t]*\r?$/m.exec(remainder);
|
|
545
|
+
const matter = closing ? remainder.slice(0, closing.index) : remainder;
|
|
546
|
+
let content = closing ? remainder.slice(closing.index + closing[0].length) : "";
|
|
547
|
+
if (content.startsWith("\r\n")) content = content.slice(2);
|
|
548
|
+
else if (content.startsWith("\n")) content = content.slice(1);
|
|
549
|
+
if (matter.trim() === "" || !["", "yaml", "yml"].includes(language)) {
|
|
550
|
+
return { content, data: {} };
|
|
551
|
+
}
|
|
552
|
+
const parsed = parseYaml2(matter);
|
|
553
|
+
return {
|
|
554
|
+
content,
|
|
555
|
+
data: parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {}
|
|
556
|
+
};
|
|
546
557
|
}
|
|
547
558
|
|
|
548
559
|
// src/mdx.ts
|
|
@@ -2051,7 +2062,7 @@ function renderMigrationFiles(bundle, options = {}) {
|
|
|
2051
2062
|
// src/url.ts
|
|
2052
2063
|
import { load } from "cheerio";
|
|
2053
2064
|
import TurndownService from "turndown";
|
|
2054
|
-
import { parse as
|
|
2065
|
+
import { parse as parseYaml3, stringify as stringifyYaml } from "yaml";
|
|
2055
2066
|
var DEFAULT_MAX_PAGES = 1e3;
|
|
2056
2067
|
var DEFAULT_MAX_TOTAL_BYTES = 1e8;
|
|
2057
2068
|
var MAX_DISCOVERED_URLS = 5e3;
|
|
@@ -2613,7 +2624,7 @@ function extractEmbeddedOpenApi(content) {
|
|
|
2613
2624
|
const match = fencePattern.exec(content);
|
|
2614
2625
|
if (!match) return { content };
|
|
2615
2626
|
try {
|
|
2616
|
-
const parsed =
|
|
2627
|
+
const parsed = parseYaml3(match[5], { maxAliasCount: 50 });
|
|
2617
2628
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return { content };
|
|
2618
2629
|
const document = parsed;
|
|
2619
2630
|
if (typeof document.openapi !== "string" && typeof document.swagger !== "string") return { content };
|