MCPcopy Create free account
hub / github.com/arktypeio/arktype / writeSkillMigrating

Function writeSkillMigrating

ark/docs/lib/writeMarkdown.ts:99–124  ·  view source on GitHub ↗
(page: string)

Source from the content-addressed store, hash-verified

97
98/** formatted as the repo formats Markdown, since the skill is checked in */
99const writeSkillMigrating = (page: string) => {
100 const prettier = createRequire(join(docsDir, "package.json")).resolve(
101 "prettier/bin/prettier.cjs"
102 )
103 // the page's intro tells people how to install the skill, so this copy
104 // starts at its sections, with the steps an agent follows first
105 const sections = page.slice(page.indexOf("\n## ") + 1).split(/^(?=## )/m)
106 const isSteps = (section: string) =>
107 section.startsWith("## Migrating a project")
108 const markdown = [
109 "# Migrating to ArkType",
110 "<!-- written from ark/docs/content/docs/(arktype)/migrating.mdx when the docs build; edit that instead -->",
111 "How to convert schemas from Zod (v3, v4 and Zod Mini), Valibot, TypeBox, Yup, Joi, Effect Schema and JSON Schema to ArkType.",
112 [...sections.filter(isSteps), ...sections.filter(s => !isSteps(s))]
113 .map(section => section.trimEnd())
114 .join("\n\n")
115 ].join("\n\n")
116 writeFileSync(
117 skillMigratingPath,
118 execFileSync(
119 process.execPath,
120 [prettier, "--stdin-filepath", skillMigratingPath],
121 { input: markdown, encoding: "utf8" }
122 )
123 )
124}
125
126const pageLink = (page: Page) =>
127 `- [${page.frontmatter.title}](${siteUrl}${page.url}.md): ${page.frontmatter.description}`

Callers 1

writeMarkdownFunction · 0.85

Calls 5

joinFunction · 0.85
isStepsFunction · 0.85
filterMethod · 0.80
resolveMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected