Skip to content

Latest commit

 

History

History
124 lines (81 loc) · 5.42 KB

File metadata and controls

124 lines (81 loc) · 5.42 KB
config

Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding


typescript-image FSL-1.1-Apache-2.0 licence npm version npm downloads PRs Welcome


Daniel Bannert's open source work is supported by the community on GitHub Sponsors


The internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference and reconciliation, and .dev.vars scaffolding. This package is internal — it is consumed by @lunora/cli and @lunora/vite so they stay in lock-step. It is published for transparency; depend on the CLI or the Vite plugin and let them call into it rather than using it directly.

Part of the Lunora framework — a type-safe, real-time backend on Cloudflare Workers + Durable Objects with a Vite-first DX.

Install

npm install @lunora/config
yarn add @lunora/config
pnpm add @lunora/config

Usage

Validate a project's wrangler.jsonc from disk. validateWranglerProject finds the config file, parses the JSONC, discovers the schema (to know whether a DB D1 binding or Vectorize bindings are required), and returns a structured report:

import { validateWranglerProject } from "@lunora/config/cloudflare";

const { report, wranglerPath } = validateWranglerProject({ projectRoot: process.cwd() });

if (!report.valid) {
    for (const error of report.errors) console.error(error);
}
for (const warning of report.warnings) console.warn(warning);

If you already hold a parsed config object, validateWranglerConfig (aliased as validateWrangler) is the pure, I/O-free form. Pass the discovered SchemaInfo so it knows which bindings the schema demands:

import { validateWranglerConfig } from "@lunora/config/cloudflare";

const report = validateWranglerConfig(wrangler, { hasD1GlobalTable: true, hasHyperdriveGlobalTable: false });
// report: { valid: boolean; errors: string[]; warnings: string[] }

To parse a JSONC config yourself, use readWranglerJsonc / findWranglerFile rather than JSON.parse — the helpers tolerate comments and trailing commas.

This README covers the basics. For the full API, options, and guides, see the documentation.

Related

  • @lunora/cli — the CLI that drives this layer; use it instead of depending here directly.
  • @lunora/vite — the Vite plugin that shares the same validator.
  • @lunora/codegen — discovers schema info used during validation.

Supported Node.js Versions

Libraries in this ecosystem make the best effort to track Node.js' release schedule. Here's a post on why we think this is important.

Contributing

If you would like to help take a look at the list of issues and check our Contributing guidelines.

Note: please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Credits

Made with ❤️ at Anolilab

This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. Anolilab is a Development and AI Studio. Contact us at hello@anolilab.com if you need any help with these technologies or just want to say hi!

License

The Lunora config package is open-sourced software licensed under the FSL-1.1-Apache-2.0.