The most simple boilerplate generator in the universe.
PL8 is a boilerplate generator focusing on simplicity, ease of use and extensibility. It doesn’t care what language or file type you want to use. Java? CSS? Python? No problem! Need to create some boilerplates? PL8 makes it easy!
- PL8 doesn't care about your tech. Java? React? SASS? It won't argue with you.
- PL8 doesn't care if you want to use Yeoman or another generator. It will still help out.
- PL8 uses a simple JSON configuration file, don't waste time with building custom generators.
- Install npm package globally:
npm i -g pl8
- Place a
pl8rc.json
config file in root of project directory. - Run
plt
orpl8
from project root to open prompt for boilerplate generation.
Title of PL8 configuration, acts as the initial prompt header.
{
title: 'Boilerplates:'
}
Output directory for new files.
{
directory: 'output/files'
}
Static variables to replace in boilerplate templates for new files.
{
vars: [{
ref: 'name', // pl8 variable for replacement ... {pl8.name} = HelloWorld
content: 'HelloWorld',
// accepts tpl: 'path/to/tpl.ext' ... path to local template
// accepts git: 'github.resource.url' ... url to github resource as template
}]
}
Allow user to input custom variables for boilerplate templates.
{
inputs: [{
title: 'What is the component name?', // prompt message to show user
ref: 'component', // pl8 variable for replacement ... {pl8.component} = User input value
}]
}
Files to output from boilerplate templates.
{
files: [{
name: 'index.js', // creates index.js file
content: 'export default {}'
}, {
name: '{pl8.name}.js', // pl8 variables will be replaced in all file names and directory paths
tpl: 'templates/tpl.js', // accepts local template files
}, {
name: '{pl8.name}-e2e.js',
git: 'https://github.com/pl8/pl8/blob/master/examples/templates/react-e2e.js', // accepts github resource urls for templates
}]
}
Allow users to choose between multiple boilerplate configurations.
// Object example
{
choices: [{
title: 'Javascript Component',
vars: [{
ref: 'name', // pl8 variable for replacement ... {pl8.name} = HelloWorld
content: 'HelloWorld',
// accepts tpl: 'path/to/tpl.ext' ... path to local template
// accepts git: 'github.resource.url' ... url to github resource as template
}],
inputs: [{
title: 'What is the component name?', // prompt message to show user
ref: 'component', // pl8 variable for replacement ... {pl8.component} = User input value
}],
files: [{
name: 'index.js', // creates index.js file
content: 'export default {}'
}, {
name: '{pl8.name}.js', // pl8 variables will be replaced in all file names and directory paths
tpl: 'templates/tpl.js', // accepts local template files
}, {
name: '{pl8.name}-e2e.js',
git: 'https://github.com/pl8/pl8/blob/master/examples/templates/react-e2e.js', // accepts github resource urls for templates
}]
}]
}
// String example
{
choices: [
'path/to/config.json',
'path/to/different/config.json',
],
}
All paths and files correspond to the examples/
directory.
// Allow user to choose config option
{
title: 'Boilerplates:',
directory: 'output/files', // outputs all files to this directory
choices: [
// string example
'examples/configs/react-component.json',
// object example
{
title: 'Javascript Component',
vars: [{
ref: 'name', // pl8 variable for replacement ... {pl8.name} = HelloWorld
content: 'HelloWorld',
// accepts tpl: 'path/to/tpl.ext' ... path to local template
// accepts git: 'github.resource.url' ... url to github resource as template
}],
inputs: [{
title: 'What is the component name?', // prompt message to show user
ref: 'component', // pl8 variable for replacement ... {pl8.component} = User input value
}],
files: [{
name: 'index.js', // creates index.js file
content: 'export default {}'
}, {
name: '{pl8.name}.js', // pl8 variables will be replaced in all file names and directory paths
tpl: 'templates/tpl.js', // accepts local template files
}, {
name: '{pl8.name}-e2e.js',
git: 'https://github.com/pl8/pl8/blob/master/examples/templates/react-e2e.js', // accepts github resource urls for templates
}]
}
]
}
// Or create some files right away
{
directory: 'output/files',
files: [{
name: 'README.md', // creates README.md file
content: '# README',
}],
}