1.0.2 • Published 3 months ago

monterey.js v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

🚀 Monterey.js

Transform JSON into JavaScript with elegance and type safety.

License npm version PRs Welcome

✨ 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):

{
    "$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

// 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:

{
    "$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