πŸš€ DAY 3 OF LAUNCH WEEK: Introducing Webhook Events for Pull Request Scans.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

templates-artist

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templates-artist

Create applications using templates

latest
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

Template Artist

Create applications using templates

Installation

npm install template-artist # using npm

yarn add template-artist # using yarn

Usage

import { TemplateArtist } from 'templates-artist';

TemplateArtist.createApp({
  answers: {
    name: 'John',
    lastname: 'Doe',
    folder: 'thisIsMyFolder',
    fileName: 'loremIpsumFileName',
  },
  destinationApp: '/application/destination/directory',
  templatePath: '/template/path/directory',
});

Creating templates using handlebarsjs

.template-directory
β”œβ”€β”€ _index.html.hbs
β”œβ”€β”€ _{{folder}}
β”‚   β”œβ”€β”€ {{fileName}}.js
β”‚   └── otherFile.txt
β”œβ”€β”€ _assets
β”‚   β”œβ”€β”€ file1.ts
β”‚   └── file2.cpp

file template

Hello world! My name is {{name}}, and my lastname is {{lastname}}

App Created

.application-destination-directory
β”œβ”€β”€ _index.html
β”œβ”€β”€ _thisIsMyFolder
β”‚   β”œβ”€β”€ loremIpsumFileName.js
β”‚   └── otherFile.txt
β”œβ”€β”€ _assets
β”‚   β”œβ”€β”€ file1.ts
β”‚   └── file2.cpp

file generated

Hello world! My name is {{name}}, and my lastname is {{lastname}}

Note: more info in https://handlebarsjs.com/guide/

Create questions within the same template

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);
  }
})();

Authors

  • Franco - Initial work - fjbalsamo
  • Victor - vicmans

See also the list of contributors who participated in this project.

FAQs

Package last updated on 04 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts