| 97 | |
| 98 | /** formatted as the repo formats Markdown, since the skill is checked in */ |
| 99 | const 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 | |
| 126 | const pageLink = (page: Page) => |
| 127 | `- [${page.frontmatter.title}](${siteUrl}${page.url}.md): ${page.frontmatter.description}` |