Skip to content

featherscloud/pinion

Repository files navigation

Pinion

CI Download Status

A fast and typesafe code generator

Pinion is a task runner and scaffolding tool that lets you create code generators for any language. Using TypeScript, it gives you full flexibility over what you can do and provides typesafe templating out-of-the box.

Quick start

Install Pinion into your project via:

npm install @featherscloud/pinion --save-dev

Then create your first generator file e.g. in generators/readme.tpl.ts like this:

import { PinionContext, toFile, renderTemplate } from '@featherscloud/pinion'

// A template for a markdown Readme file
const readme = () => `
# Hello world

This is a readme generated by Pinion

Copyright (c) ${new Date().getFullYear()}
`

export const generate = (init: PinionContext) =>
  Promise.resolve(init)
    // Render the readme template
    .then(renderTemplate(readme, toFile('readme.md')))

Then run

npx pinion generators/readme.tpl.ts

Documentation

Head over to the Pinion documentation for the full documentation.

License

Copyright (c) 2024 Feathers Cloud Inc.

Licensed under the MIT license.