0.0.29 • Published 5 years ago

lz-cli v0.0.29

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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',
    },
  ],
}

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

0.0.29

5 years ago

0.0.28

5 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago