Skip to content

Introducing Pinion

The typesafe generator toolkit.

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

interface Context extends PinionContext {
  name: string
}

// The file content as a template string
const readme = ({ name }: Context) =>
  `# Hello ${name}

Welcome to Pinion!

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

// Export the generator and render the template
export const generate = (init: Context) =>
  Promise.resolve(init)
    .then(
      prompt({
        name: {
          type: 'input',
          message: 'What is your name?'
        }
      })
    )
    .then(renderTemplate(readme, toFile('readme.md')))