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

lempit

v0.4.0

Published

Project scaffolder

Downloads

21

Readme

lempit

A simple CLI project scaffolder similar to Khaos.

npm version Build Status GitHub license

Installation

Prerequisites: node.js, npm and git.

$ npm install -g lempit

Usage

lempit init

Is to create project boilerplate from local template or git repository template.

$ lempit init <template-name> <project-name> [options]

Arguments

template-name

Git repository or local folder that contains project template. To create project from https://github.com/lempit/koa-typescript you can simply specify lempit/koa-typescript as the template-name. For other repositories other than Github you have to specify the name of the repository in front of template directory:

GitHub - github:owner/template-name or simply owner/template-name

GitLab - gitlab:owner/template-name

Bitbucket - bitbucket:owner/template-name

project-name

The name of project.

options

-c, --clean clean target directory

-h, --help output usage information

Example

$ lempit init lempit/koa-typescript my-project

Template

To create a template you just need to create files filled with mustache template tags and put it under directory named template. Lempit works like Khaos with some additional features:

Handlebars helpers

You can use two commonly used Handlebars helpers raw-helper, if, if_eq and unless_eq. The if_eq and unless_eq helpers intended to create a multiple choice questions. Thanks to vue-cli for the idea!

Here's the list of available helpers:

| Helper | Description | | --- | --- | | Logics | | raw-helper | Raw Blocks. | | if or # | The if blocks that resulting (Yes/No) question. | | if_eq | More like swicth to create multiple choice. | | unless_eq | Unless equals blocks. | | Strings | | lowercase | Converts string, as space separated words, to lower case | | camelcase | Converts string to camel case. | | uppercase | Converts string, as space separated words, to upper case. | | upperfirst | Converts the first character of string to upper case. | | startcase | Converts string to start case. | | kebabcase | Converts string to kebab case. | | snakecase | Converts string to snake case. | | Paths | | rela | Convert an absolute path to a relative path. |

Metadata file

While asking user to answer the questions, you may want to display a words rather than variable names. All you need to do is to create file either meta.json or meta.js under the root directory of your template. If you are using Handlebars helpers if_eq or unless_eq, then metadata file is required to define the choices.

Example

./template/package.json

{
    "name": "{{name}}",
    "version": "0.0.1",
    "description": "{{description}}",
{{#if preferGlobal}}
    "preferGlobal": true,
{{/if}}
{{#unless_eq license "mit"}}
    "private": true,
{{/unless_eq}}
    "license": "{{#if_eq license "mit"}}MIT{{/if_eq}}{{#if_eq license "isc"}}ISC{{/if_eq}}"    
}

./meta.json

{
  "prompts": {
    "name": {
      "message": "Name of project",
      "required": true
    },
    "preferGlobal": {
      "message": "Prefer global?"
    },
    "license": {			
      "message": "Pick an appropriate license",
      "choices": [
        {
          "name": "MIT (https://opensource.org/licenses/MIT)",
          "value": "mit",
          "short": "MIT"
        },
        {
          "name": "ISC (https://opensource.org/licenses/ISC",
          "value": "isc",
          "short": "ISC"
        }
      ]
    }
  }
}

Prompts:

Prompts

Result:

{
    "name": "cool-project",
    "version": "0.0.1",
    "description": "Some cool project!",
    "preferGlobal": true,
    "private": true,
    "license": "ISC"    
}

A Khaos template should be works too for Lempit.

lempit new

Is to generate project files in a project. This command is very usefull when you often writing code using similar pattern. All you have todo is to store your templates in .lempit directory under project root directory, then execute lempit new <directory or file in .lempit directory> <destination directory or file> [options].

Put your meta.json as well as if needed in .lempit directory.

Use -f or --file options if you want to generate single file with different name.

Structure

root directory
├── .lempit
|    ├── meta.json              # lempit metadata            
|    ├── foo_template_dir       # a template directory
|    |   ├── foo1.js            #   template files
|    |   └── foo2.js
|    ├── baz_template_dir       # another template directory
|    |   ├── baz1.js            #   template files
|    |   └── baz2.js
|    └── foo_template.js        # a template file
└── Your project dir/files      # actual project files

Usage example

Generate from directory
$ lempit new foo_template_dir ./components/foo

Generate files (foo1.js and foo2.js) from /.lempit/foo_template_dir directory into /components/foo. This action will creates /components/foo under you root project directory automatically.

Generate from file
$ lempit new foo_template_dir/foo1.js ./components/foo

Generate file from /.lempit/foo_template_dir/foo1.js directory into /components/foo directory.

Generate from file as new file name (-r or --rename option)
$ lempit new foo_template_dir/foo1.js ./components/meh1.js -r

Generate file from /.lempit/foo_template_dir/foo1.js directory into /components/meh1.js.

Directory Maps

You can specify the directory maps against the templates, so lempit will generates the template automatically into specified directory.

Example

./.lempit/meta.json

{
  "maps": {
    "actions": "the-actions"
  }
}

Everytime you generate template(s) from actions lempit generates the results under /the-actions directory.

Example template: ./lempit/actions/bar.js

Execute:

lempit new actions foo --> /the-actions/foo/bar.js

lempit new actions/bar.js foo --> /the-actions/foo/bar.js

lempit new actions/bar.js foo/meh.js -r --> /the-actions/foo/meh.js

lempit list

This is more like a templating wizard. When you execute lempit list it will list available templates in .lempit directory and allows you to choose one and follow the steps to generate the file(s).

Credits

Khaos

Metalsmith

handlebarsjs

Inquirer.js

vue-cli

License

MIT