Skip to content

Introducing Pinion

The typesafe generator toolkit.

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

interface Context extends PinionContext {
  name: string
}

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

Welcome to Pinion!

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

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