rehype-npm-command.ts — ui Source File
Architecture documentation for rehype-npm-command.ts, a typescript file in the ui codebase. 2 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR fd3c35e5_783f_b703_3e23_80ad367b4a7a["rehype-npm-command.ts"] 0730df87_79db_5696_d5e4_371255b3036a["unist"] fd3c35e5_783f_b703_3e23_80ad367b4a7a --> 0730df87_79db_5696_d5e4_371255b3036a fcbb6195_57aa_1339_fa5f_694d53020f20["unist-util-visit"] fd3c35e5_783f_b703_3e23_80ad367b4a7a --> fcbb6195_57aa_1339_fa5f_694d53020f20 3ab0029b_bc98_e23e_7c0d_e96099aed850["contentlayer.config.js"] 3ab0029b_bc98_e23e_7c0d_e96099aed850 --> fd3c35e5_783f_b703_3e23_80ad367b4a7a style fd3c35e5_783f_b703_3e23_80ad367b4a7a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
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"
)
}
// npm create.
if (node.properties?.["__rawString__"]?.startsWith("npm create")) {
const npmCommand = node.properties?.["__rawString__"]
node.properties["__npmCommand__"] = npmCommand
node.properties["__yarnCommand__"] = npmCommand.replace(
"npm create",
"yarn create"
)
node.properties["__pnpmCommand__"] = npmCommand.replace(
"npm create",
"pnpm create"
)
node.properties["__bunCommand__"] = npmCommand.replace(
"npm create",
"bun create"
)
}
// 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"
)
}
// npm run.
if (node.properties?.["__rawString__"]?.startsWith("npm run")) {
const npmCommand = node.properties?.["__rawString__"]
node.properties["__npmCommand__"] = npmCommand
node.properties["__yarnCommand__"] = npmCommand.replace(
"npm run",
"yarn"
)
node.properties["__pnpmCommand__"] = npmCommand.replace(
"npm run",
"pnpm"
)
node.properties["__bunCommand__"] = npmCommand.replace("npm run", "bun")
}
})
}
}
Domain
Subdomains
Functions
Dependencies
- unist
- unist-util-visit
Imported By
Source
Frequently Asked Questions
What does rehype-npm-command.ts do?
rehype-npm-command.ts is a source file in the ui codebase, written in typescript. It belongs to the ComponentRegistry domain, Styles subdomain.
What functions are defined in rehype-npm-command.ts?
rehype-npm-command.ts defines 1 function(s): rehypeNpmCommand.
What does rehype-npm-command.ts depend on?
rehype-npm-command.ts imports 2 module(s): unist, unist-util-visit.
What files import rehype-npm-command.ts?
rehype-npm-command.ts is imported by 1 file(s): contentlayer.config.js.
Where is rehype-npm-command.ts in the architecture?
rehype-npm-command.ts is located at deprecated/www/lib/rehype-npm-command.ts (domain: ComponentRegistry, subdomain: Styles, directory: deprecated/www/lib).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free