0.0.14 • Published 8 months ago

@noodlestan/designer-generators v0.0.14

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

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

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: module or exports fields to package.json as 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 - uses tsc --watch.
  • $ npm run build - uses tsc to build dist/cjs.
  • $ npm run test / npm run test:watch - uses mocha + 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.

0.0.14

8 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago