Something went wrong. Try again.
Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol.
Something went wrong. Try again.
1.2 kB · 26 lines
TypeScript
at main
123456789101112131415161718192021222324252627#!/usr/bin/env bun// Regenerate crates/wispplace-core/src/mime_table.rs: the extension -> type map// that the TypeScript CLI's `mime-types` (3.0.2) `lookup` used, so deployed// files keep their Content-Type and gzip decision.//// usage (from the repo root): bun cli-rs/scripts/mime-table.ts// MIME_TYPES_DIR overrides where mime-types is loaded from.import { writeFileSync } from 'node:fs'import { join } from 'node:path'
const dir = process.env.MIME_TYPES_DIR ?? join(import.meta.dir, '../../cli/node_modules/mime-types')const { types } = await import(join(dir, 'index.js'))const { version } = await import(join(dir, 'package.json'))
const rows = Object.entries(types as Record<string, string>) .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)) .map(([ext, type]) => ` (${JSON.stringify(ext)}, ${JSON.stringify(type)}),`)
const out = `// @generated by cli-rs/scripts/mime-table.ts from mime-types ${version}. Do not edit./// Extension (lowercase, no dot) to MIME type, sorted by extension.pub static TYPES: &[(&str, &str)] = &[${rows.join('\n')}];`writeFileSync(join(import.meta.dir, '../crates/wispplace-core/src/mime_table.rs'), out)console.log(`${rows.length} extensions from mime-types ${version}`)