@rbleattler/omp-ts-typegen
v0.2025.3580004
Published
TypeScript type definitions for Oh My Posh schema
Maintainers
Readme
Oh-My-Posh TypeScript Type Generator
Oh-my-posh (JanDeDobbeleer
oh-my-posh | github) is "A prompt theme engine for any shell." This project generates typescript types from the oh-my-posh schema. These types can then be used in other typescript projects to validate and work with oh-my-posh configuration files.
The typescript/javascript in this directory is used to generate typescript types from the oh-my-posh (oh-my-posh.dev) schema. These types can then be used in other typescript projects to validate and work with oh-my-posh configuration files.
For a detailed explanation of the schema, see schema-explained.md.
Goals
- Generate typescript types from the
oh-my-poshschema- Which can be used to:
- Validate
oh-my-poshconfiguration files - Work with
oh-my-poshconfiguration files in typescript projects - Generate documentation for
oh-my-poshconfiguration files - Build
oh-my-poshconfiguration files programmatically
- Validate
- Which are easy to:
- Understand
- Use
- Maintain
- Extend
- Which can be used to:
- Generate documentation for
oh-my-poshconfiguration files- Which is easy to:
- Understand
- Use
- Maintain
- Extend
- Which is easy to:
Installation
# Clone the repository
git clone https://github.com/yourusername/omp-ts-typegen.git
cd omp-ts-typegen
# Install dependencies
npm installHow It Works
This project automatically generates TypeScript type definitions from the Oh My Posh JSON schema:
- The script fetches the latest schema from the Oh My Posh repository
- The schema is cached locally for future reference
- quicktype is used to convert the JSON schema into TypeScript types
- The generated types are saved to the
src/types/omp.tsfile - These types are then exported via the main entry point (
src/index.ts)
A GitHub workflow runs nightly to check for schema updates and regenerate types if needed.
Usage
Generating Types
# Generate types from the Oh My Posh schema
npm run generate-types
# Test the generated types against all Oh My Posh themes
# This will also generate a theme-validation.md report
npm run test-types
# Build the package
npm run buildValidation Report
When running npm run test-types, the script will:
- Clone the Oh My Posh repository and test all themes against the generated types
- Generate a markdown report (
theme-validation.md) showing which themes are valid or invalid - Create a custom SVG badge showing validation status
- Exit with a non-zero code if any themes are invalid
The validation report includes:
- A summary of validation results (total themes, valid count, invalid count)
- A table listing all themes with links to their source files
- Status indicators showing which themes pass validation
- A custom SVG badge that is displayed in the README
Using the Generated Types
Once you've installed this package in your project, you can use the generated types:
import { Config } from '@rbleattler/omp-ts-typegen';
// Use the types to validate or work with Oh My Posh config files
const myConfig: Config = {
// Your config here
};Project Structure
/scripts- Contains the TypeScript scripts for generating and testing typesgenerate-types.ts- Fetches the schema and generates typestest-types.ts- Tests the generated types against sample configsvalidator.ts- Provides validation functionalityupdate-changelog.ts- Updates the changelog when the types change
/src- Contains the generated TypeScript typestypes/omp.ts- The generated TypeScript typesindex.ts- Exports the types for use in other projects
/cache- Stores the cached schema for comparison/cache/oh-my-posh- Cached clone of the Oh My Posh repository for validation
/temp- Temporary directory used during testingtheme-validation.md- Report of theme validation resultstheme-validation-badge.svg- Visual badge showing theme validation status/.github/workflows- CI/CD workflows, including the nightly type generation
Requirements
- Node.js 18+
- ESM-compatible environment (for chalk v5+ and other ESM dependencies)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
