# lz-cli

> scaffold for the masses

Latest version **0.0.29** (published 2018-11-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install lz-cli
pnpm add lz-cli
yarn add lz-cli
bun add lz-cli
```

Provides the command `lz`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.29 |
| Published | 2018-11-29 |
| First published | 2018-09-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 15 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | alexrqs |

## Links

- npm: https://www.npmjs.com/package/lz-cli
- npm.io page: https://npm.io/package/lz-cli

## Dependencies (15)

- [clui](https://npm.io/package/clui.md) ^0.3.6
- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [clear](https://npm.io/package/clear.md) ^0.1.0
- [figlet](https://npm.io/package/figlet.md) ^1.2.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.2
- [inquirer](https://npm.io/package/inquirer.md) ^6.2.0
- [commander](https://npm.io/package/commander.md) ^2.17.1
- [is-windows](https://npm.io/package/is-windows.md) ^1.0.2
- [simple-git](https://npm.io/package/simple-git.md) ^1.103.0
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^6.0.5
- [parse-gitignore](https://npm.io/package/parse-gitignore.md) ^1.0.1
- [update-notifier](https://npm.io/package/update-notifier.md) ^2.5.0
- [lodash-inflection](https://npm.io/package/lodash-inflection.md) ^1.5.0

## Recent versions

- 0.0.29 (latest) — 2018-11-29
- 0.0.28 — 2018-11-23
- 0.0.27 — 2018-10-25
- 0.0.26 — 2018-10-15
- 0.0.25 — 2018-10-05
- 0.0.24 — 2018-10-05
- 0.0.23 — 2018-10-05
- 0.0.22 — 2018-10-05
- 0.0.21 — 2018-10-05
- 0.0.20 — 2018-10-05
- 0.0.19 — 2018-10-05
- 0.0.18 — 2018-10-05
- 0.0.17 — 2018-10-05
- 0.0.16 — 2018-10-04
- 0.0.15 — 2018-10-02
- … 14 more at https://npm.io/package/lz-cli/versions

## README

# lz-cli

scaffold for the masses

[![circleci badge](https://img.shields.io/circleci/project/github/alecsgone/lz-cli/master.svg)](https://circleci.com/gh/alecsgone/workflows/lz-cli)

## Usage
- [Install](#install)
- [Create your template](#create-your-template)
- Use case: [Bootstrap a project from github](#bootstrap-a-project-from-github)
- Use case: [Scaffold a files from local source](#scaffold-a-files-from-local-source)

## 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
```sh
$ 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

```json
"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`](https://github.com/SBoudrias/Inquirer.js#readme)
```js
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

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

### Run it

```
$ npm run new:foo
```

## CLI

```console
$ 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

```js
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
  ```sh
  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

---
_Source: https://npm.io/package/lz-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
