* Copy the design-system app into a new one for ui-library. * Remove unneeded content. * Add supabase config. * Cleanup the css. * Add bunch of packages. * Cleanup the registry. * Regenerate the registry. * Add needed components for documenting components. * Add the pages for the components. * Fix the RegistryBlock. * Various fixes. * Add a turbo definition for ui-library. * Rename Remix to React Router. * Reorder the pages for all frameworks. * Remove the bottom pager. * Fix the pages and command menu. * Various fixes. * Minor fixes. * Add ai editor rules. * Various fixes. * Add local supabase env vars. * Try to fix a package error. * Bunch of various fixes. * Fix lint errors.
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
import { UnistNode, UnistTree } from 'types/unist'
|
|
import { visit } from 'unist-util-visit'
|
|
|
|
export function rehypeNpmCommand() {
|
|
return (tree: UnistTree) => {
|
|
visit(tree, (node: UnistNode) => {
|
|
if (node.type !== 'element' || node?.tagName !== 'pre') {
|
|
return
|
|
}
|
|
|
|
// npm install.
|
|
if (node.properties?.['__rawString__']?.startsWith('npm install')) {
|
|
const npmCommand = node.properties?.['__rawString__']
|
|
node.properties['__npmCommand__'] = npmCommand
|
|
node.properties['__yarnCommand__'] = npmCommand.replace('npm install', 'yarn add')
|
|
node.properties['__pnpmCommand__'] = npmCommand.replace('npm install', 'pnpm add')
|
|
node.properties['__bunCommand__'] = npmCommand.replace('npm install', 'bun add')
|
|
}
|
|
|
|
// npx create.
|
|
if (node.properties?.['__rawString__']?.startsWith('npx create-')) {
|
|
const npmCommand = node.properties?.['__rawString__']
|
|
node.properties['__npmCommand__'] = npmCommand
|
|
node.properties['__yarnCommand__'] = npmCommand.replace('npx create-', 'yarn create ')
|
|
node.properties['__pnpmCommand__'] = npmCommand.replace('npx create-', 'pnpm create ')
|
|
node.properties['__bunCommand__'] = npmCommand.replace('npx', 'bunx --bun')
|
|
}
|
|
|
|
// npx.
|
|
if (
|
|
node.properties?.['__rawString__']?.startsWith('npx') &&
|
|
!node.properties?.['__rawString__']?.startsWith('npx create-')
|
|
) {
|
|
const npmCommand = node.properties?.['__rawString__']
|
|
node.properties['__npmCommand__'] = npmCommand
|
|
node.properties['__yarnCommand__'] = npmCommand
|
|
node.properties['__pnpmCommand__'] = npmCommand.replace('npx', 'pnpm dlx')
|
|
node.properties['__bunCommand__'] = npmCommand.replace('npx', 'bunx --bun')
|
|
}
|
|
})
|
|
}
|
|
}
|