Want to use LUMOS for Solana schema generation but don't want to install Rust? The @getlumos/cli npm package has you covered!
Why Use the npm Package?
- No Rust Toolchain Required - Works with Node.js only
- Cross-Platform - Single package for all platforms
- Programmatic API - Use LUMOS in build scripts
- TypeScript Support - Full type definitions included
- Lightweight - 261 KB compressed
Installation
Global Installation
npm install -g @getlumos/cli
# or
yarn global add @getlumos/cli
# or
pnpm add -g @getlumos/cli
Verify installation:
lumos --version
# Output: 0.1.0
No Installation (npx)
Run directly without installing:
npx @getlumos/cli generate schema.lumos
CLI Usage
Generate Code
# Basic usage
lumos generate schema.lumos
# With custom output paths
lumos generate schema.lumos \
--output-rust src/generated.rs \
--output-typescript src/generated.ts
Add to package.json Scripts
{
"scripts": {
"codegen": "lumos generate schema.lumos",
"prebuild": "npm run codegen"
}
}
Programmatic API
Use LUMOS in your JavaScript/TypeScript code:
import { generate, validate } from '@getlumos/cli';
// Validate first
const validation = await validate('schema.lumos');
if (!validation.valid) {
console.error('Schema validation failed');
process.exit(1);
}
// Generate
const result = await generate('schema.lumos', {
outputRust: 'src/generated.rs',
outputTypeScript: 'src/generated.ts'
});
console.log('Generated Rust code:', result.rust);
console.log('Generated TypeScript code:', result.typescript);
Build Tool Integration
Vite Plugin
import { Plugin } from 'vite';
import { generate } from '@getlumos/cli';
export function lumosPlugin(schemaPath: string): Plugin {
return {
name: 'vite-plugin-lumos',
async buildStart() {
await generate(schemaPath);
}
};
}
Webpack Plugin
const { generate } = require('@getlumos/cli');
class LumosPlugin {
constructor(schemaPath) {
this.schemaPath = schemaPath;
}
apply(compiler) {
compiler.hooks.beforeCompile.tapPromise('LumosPlugin', async () => {
await generate(this.schemaPath);
});
}
}
CI/CD Integration
GitHub Actions
name: Generate LUMOS Code
on: [push, pull_request]
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install
- run: npx @getlumos/cli generate schema.lumos
npm vs Rust CLI Comparison
| Feature | npm (@getlumos/cli) |
Rust (lumos-cli) |
|---|---|---|
| Installation | npm install -g |
cargo install |
| Requirements | Node.js 16+ | Rust toolchain |
| Size | 261 KB | ~10 MB |
| Speed | WASM (~10-20% slower) | Native (fastest) |
| Programmatic API | JavaScript/TypeScript | Rust only |
Choose npm if:
- You don't have Rust installed
- You want programmatic API access
- You're building JavaScript/TypeScript projects
Choose Rust if:
- You want maximum performance
- You need LSP integration
Get Started
npx @getlumos/cli generate schema.lumos
- npm Registry: https://www.npmjs.com/package/@getlumos/cli
- Documentation: https://docs.lumos-lang.org/guides/npm-package/
- GitHub: https://github.com/getlumos/lumos
Questions? Drop them in the comments!
Top comments (0)