@noodlestan/designer-generators v0.0.14
Designer Decisions - Generators
Generate design tokens, TS and CSS code, and schemas for input validation.
How to use
š Documentation
!WARNING Early days. Follow our progress on the Github project
Generating schemas
The createSchemaGenerator() function generates JSON schemas for TS types.
In this repository's build tools you can find a complete working example.
The generate.ts script generates the JSON schemas for the built-in decision models and primitives. It is provided with a SchemaGeneratorConfig object that describes where to locate the TS types for models and primitives (in the @noodlestan/designer-decisions package) and a target directory inside the @noodlestan/designer-schemas package, from where the schemas are then published to NPM.
Usage (abbreviated):
import { createSchemaGenerator } from '@noodlestan/designer-generators';
const generator = createSchemaGenerator(TARGET_DIR, SCHEMA_CONFIGS);
await generator.discover();
const files = await generator.generate();
console.info(`š Generated ${files.length} schemas`);See also
- š Guides / Loading and Validating Decisions
- š Models / Schemas
- š API / @noodlestan/designer-generators
Development
Make sure you README first.
!IMPORTANT This library contains code that is used to generate artifacts (JSON schemas) in other packages of this repository.
The entry point is "build:schemas": "ts-node scripts/generate.ts" in the tools/build support package.
Build Targets
!IMPORTANT Do not add
type: moduleorexportsfields topackage.jsonas this will break Node.js ESM consumers.
This library is packaged for use both in bundlers such as Vite and Astro, as well as Node.js environments (CJS/ESM), and ts-node. For Node.js consumers, even those using import or await import() syntaxes, all imports resolve to the CJS build. This is only possible when the "type": "module" and "exports" fields are both omitted from the library's package.json.
Scripts
- $
npm run dev- usestsc --watch. - $
npm run build- usestscto builddist/cjs. - $
npm run test/npm run test:watch- usesmocha+ts-node/register. - $
npm run lint/npm run lint:fix- uses @noodlestan/eslint-config.
MIT License
Copyright (c) 2024 Noodlestan.
Published under a MIT license.