πŸš€ Monterey.js

Transform JSON into JavaScript with elegance and type safety.

License npm version PRs Welcome

The language is still work in progress, so depending on the state of it right now, it wont be finished. Issues and bugs can be created at the Issues area in Github.

✨ Why Monterey?

Ever wished JSON could do more? Monterey.js bridges the gap between static configuration and dynamic code. Write your logic in a familiar JSON format and let Monterey transform it into production-ready JavaScript.

β€œConfiguration as code, but make it JSON” - that’s Monterey’s philosophy.

πŸš€ Quick Start

Get up and running in seconds:

# Install globally using your favorite package manager
npm i -g monterey.js      # npm
pnpm add -g monterey.js   # pnpm
yarn global add monterey.js   # yarn

πŸ“ Example

Here’s how simple it is to use Monterey:

1️⃣ Create your Monterey file (hello.monjson):

example.monjson
{
    "$schema": "https://raw.githubusercontent.com/AbdullahCXD/monterey.js/refs/heads/develop/schema/monterey.schema.json",
    "header": {
        "montereyVersion": "1.0.0"
    },
    "variables": [
        {
            "name": "greeting",
            "value": "Hello, World! 🌍",
            "immutable": true
        }
    ]
}

2️⃣ Transform it to JavaScript using the CLI:

# Transform a single file
monterey build hello.monjson

# Or watch for changes
monterey watch hello.monjson

# Specify output directory
monterey build hello.monjson --out dist/

🎯 Features

  • πŸ’Ž Type-Safe - Built with TypeScript for robust development

  • πŸ”„ JSON-Powered - Write in JSON, get JavaScript

  • 🧩 Extensible - Create custom transpilers for your needs

  • πŸ›‘οΈ Version Control - Built-in version compatibility checks

  • 🎨 Modern Syntax - Clean, readable output code

  • πŸ“ Schema Validation - Catch errors before they happen

πŸ› οΈ CLI Commands

# Build a file or directory
monterey build <input> [options]

# Watch mode
monterey watch <input> [options]

# Check file syntax
monterey check <input>

# Show version
monterey --version

Options:
  --out, -o     Output directory
  --watch, -w   Watch for changes
  --minify, -m  Minify output
  --help, -h    Show help

πŸ› οΈ API

Core Components

transpiler.js
// Create a new instance
const monterey = new Monterey();

// Choose your transpiler
monterey.setTranspiler(customTranspiler); // Optional

// Build methods
const fromFile = monterey.buildFile("input.monjson");
const fromString = monterey.build(jsonString);

File Structure

Your Monterey files follow this intuitive structure:

example.monjson
{
    "$schema": "...",
    "header": {
        "montereyVersion": "1.0.0"
    },
    "variables": [...],
    "functions": [...],
    "classes": [...]
}

🚨 Error Handling

Monterey provides clear, actionable error messages:

CodeDescription
OUTDATEDTime to update Monterey
INVALID_VERSIONVersion mismatch
TRANSPILE_ERRORTranspilation failed
BUILD_ERRORBuild process error
INVALID_EXTWrong file extension
NO_TRANSPILERTranspiler not set
FN_NOT_FOUNDFile not found

🚧 Development

# Get started
pnpm install

# Build
pnpm build

# Test
pnpm test

🀝 Contributing

Contributions make Monterey better! Whether it’s:

  • πŸ› Fixing bugs

  • ✨ Adding features

  • πŸ“ Improving docs

  • 🎨 Enhancing design

All contributions are welcome! Check out our Contributing Guide to get started.

πŸ“„ License

MIT Β© AbdullahCXD


Made with ❀️ by AbdullahCXD