Create applications using templates
npm install template-artist # using npm
yarn add template-artist # using yarn
import { TemplateArtist } from 'templates-artist';
TemplateArtist.createApp({
answers: {
name: 'John',
lastname: 'Doe',
folder: 'thisIsMyFolder',
fileName: 'loremIpsumFileName',
},
destinationApp: '/application/destination/directory',
templatePath: '/template/path/directory',
});
.template-directory
├── _index.html.hbs
├── _{{folder}}
│ ├── {{fileName}}.js
│ └── otherFile.txt
├── _assets
│ ├── file1.ts
│ └── file2.cpp
file template
App Created
.application-destination-directory
├── _index.html
├── _thisIsMyFolder
│ ├── loremIpsumFileName.js
│ └── otherFile.txt
├── _assets
│ ├── file1.ts
│ └── file2.cpp
file generated
Hello world! My name is John, and my lastname is Doe
Note: more info in https://handlebarsjs.com/guide/
Create a simple nodejs app, install "template-artist" and finally create "template" folder with html file inside
mkdir test-template && cd ./test-template
npm init -y
npm install template-artist
touch index.js
mkdir ./template
echo "{{name}}" > ./template/index.html.hbs
/*
This script will generate a json file inside the root directory of the app with your questions called template-questions.json.
*/
import { TemplateArtistQuestions } from 'templates-artist';
(() => {
TemplateArtistQuestions.generateQuestions({
questions: [
{
type: 'input',
message: 'Type your name',
name: 'name',
default: 'Jhon',
validation: {
opts: ['required'],
messageError: 'your name is required',
},
},
],
jsonFileName: 'template-questions'
});
})();
Test your template and questions and answers
/*
This script will test your template, test your answers and questions match
*/
import { TemplateArtistQuestions, TemplateArtist } from 'templates-artist';
(() => {
const questions = TemplateArtistQuestions.readQuestions(
// path to questions file
);
const errors = TemplateArtist.test({
answers,
questions,
templatePath: 'templateFolderPath'
});
if (errors.length == 0) {
console.log('good!', errors);
} else {
console.error('something wnet wrong!', errors);
}
})();
See also the list of contributors who participated in this project.