Created
January 21, 2024 23:15
-
-
Save daffl/19ff04a42c5066e172523a4f73297892 to your computer and use it in GitHub Desktop.
Getting started with Pinion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment