npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generate-template

v1.0.5

Published

CLI Tool to generate templates files

Downloads

5

Readme

generate-template

A simple CLI Tool to generate-template.

  1. Motivation
  2. Getting started
  3. Common usage
  4. Command line options
  5. Custom configuration
    1. Fix Linter issues
    2. Override defaults

Motivation

Code snippets exist for long in code editors, but what if you want to publish and share easy-to-use templates within a team for a project ?

When installed inside a project, generate-template enables you to create files based on .template files you created in your project.

Getting started

  1. run yarn add --dev generate-template (or equivalent npm command)
  2. [OPTIONAL] run generate-template --init
    Note: this will create a .templates folder at your project root, with a example.template.js file.
  3. Create an empty [template-name].template.[extension] file anywhere in your project (we recommand to keep them in .templates/ folder created at step 2)
  4. Write inside your template code. You can use {{ variable }} syntax anywhere inside to create variables you will be asked for values at generation time (step 6). You can check example file .templates/example.template.js generated at step 2.
  5. Navigate in command line in the folder where you want to create a new file using your template.
  6. run generate-template new.
  7. Select in appearing list the template you want to use.
    Note: every **.template.* file you created in your project will be listed.
  8. If you added {{ variables }} in your template, you will be asked for their values.
  9. Enter a filename for you new file when asked.
  10. That's it! A [filename].[extension] has been created in directory you ran generate-template new command in.

Common usage

After you created your common files templates:

  1. Navigate to directory where you want to generate a file.
  2. run generate-template new.
  3. Answers appearing questions.

Command line options

| command | alias | options | Description | | :------ | :---- | :------ | :--------------------------------------------------------- | | init | i | none | Create .templates folder, along with an example template | | new | n | none | Launch generator to create a new file |

Custom configuration

Fix linter issues

If you have a linter installed, chances are you will get errors with {{ name }} values in your .template.js files. To fix it, please ignore template files in your linter.

| linter | fix | | :----: | :----------------------------------------------------------------------------------------------------- | | eslint | add (or edit) a .eslintignore file at your project root, and add this ignored glob **/*.template.* |

Override config defaults

You can create a config.json file in .templates folder to override defaults. Find below all configuration overrides available:

| key | default | Description | | --------- | :---------: | -----------------------: | | extension | ".template" | templates file extension |

Example of custom configuration:

{
  "extension": ".tpl" // [name].tpl.[extension] files will now be used
}

To do

  • Add more configuration
  • Add typescript
  • Add tests