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

lz-cli

v0.0.29

Published

scaffold for the masses

Downloads

33

Readme

lz-cli

scaffold for the masses

circleci badge

Usage

Install

Local and global installs will work, local will be useful if you want to combine it with NPM scripts, global to be used everywhere to start projects from scratch

  • Globally
$ npm i -g lz-cli # this will make the `lz` command available
  • Locally:
$ npm i lz-cli -D

and modify your package.json to use it

"scripts": {
 "new:foo": "lz generate foo"
}

Create your template

  • Inside a template folder, create the folder structure and files that you wish to replicate
  • Use <%= variableName %> inside your files to replace the value later when the bootstrap is happening
  • create a lz.config.js sibling to the template/ folder on the root path of the project, the file should include a prompt key to stablish the variables same as you will with inquirer
module.exports = {
  prompt: [
    {
      type: 'input',
      name: 'variableName',
      message: 'variable Name?',
      default: 'user',
    },
  ],
}
  • example: https://github.com/alecsgone/lz-express/blob/master/lz.config.js

Bootstrap a project from github

Probably you want the global install or simply run it with npx lz-cli after you have your template ready use the gh command with your user and repo to copy the structure from github on an empty folder

lz gh user/repo

Scaffold a files from local source

TBD

Create your config file

create a file named lz.config.js in the project root directory

module.exports: {
  foo: {
    template: 'foo/bar',
    prompt: { ... },
    inserts: [ {}, ...],
  },
}

Run it

$ npm run new:foo

CLI

$ lz --help

  Usage: lz [options] [command]

  Options:

    -v, --version       output the version number
    -h, --help          output usage information

  Commands:

    github <user/repo>  Generate scaffold from github user/repo
    gh <user/repo>      (alias) like github but shorter
    folder <path>       Generate scaffold from folder path
    f <path>            (alias) like folder but shorter
    generate <key>      Generate scaffold from config file key
    g <key>             (alias) like config but shorter

Configuration

module.exports = {
  scaffold: {
    template: 'scaffold',
    prompt: [
      {
        type: 'input',
        name: 'name',
        message: 'Scaffold Name?',
        default: 'user',
      },
    ],
    inserts: [
      {
        path: 'routes/index.js',
        pattern: 'register:new:routes',
        echo: "router.use('/', <%= name %>Routes)",
      },
      {
        path: 'routes/index.js',
        pattern: 'import:new:routes',
        echo: "const <%= name %>Routes = require('./<%= name %>')",
      },
    ],
  },
}

Scaffold

lz allows you 3 different types of scaffold

github

lz github user/repo will grab the repo and replicate the structure from the template folder and will use the config from the root.

folder

lz folder ../foo/bar replicates the folder structure replacing variables

Examples

  • Simple webpack app https://github.com/alecsgone/scaffold-web (it will probably grow to include babel/sass/html)
  • ExpressJS https://github.com/alecsgone/lz-express using this as
    lz gh alecsgone/lz-express
    Will not only give you the bare-bones for an express app but it also contains template creator to scaffold controllers, routes and models once the app is created