opencode/packages/cli-rs/script/gen/mime.ts
Simon Klee 6b1df0cceb
feat(cli-rs): add the native CLI and TUI (#63477)
Add packages/cli-rs, an OpenCode client written in Rust on OpenTUI's Rust crates. It is a client only.
2026-11-22 00:07:01 +01:00

19 lines
864 B
TypeScript

// Generates the extension-to-MIME table used for `run -f` attachments.
import { createRequire } from "node:module"
const require = createRequire(new URL("../../../util/package.json", import.meta.url).pathname)
const types: Record<string, string> = require("mime-types").types
const entries = Object.entries(types).toSorted(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
const lines = [
"// Generated by script/gen/mime.ts from the `mime-types` package. Do not edit.",
"",
"/// `(extension, type)`, sorted by extension.",
"pub const TYPES: &[(&str, &str)] = &[",
...entries.map(([extension, type]) => ` (${JSON.stringify(extension)}, ${JSON.stringify(type)}),`),
"];",
"",
]
const file = new URL("../../crates/cli/src/run/mime.rs", import.meta.url).pathname
await Bun.write(file, lines.join("\n"))
console.log(`mime: ${entries.length} extensions`)