# generator-yogini

> Simple, prompt-driven scaffolding for continuously evolving boilerplates.

Latest version **2.0.1** (published 2021-01-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install generator-yogini
pnpm add generator-yogini
yarn add generator-yogini
bun add generator-yogini
```

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2021-01-23 |
| First published | 2020-11-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 5 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Raine Revere |
| Maintainers | raine |
| Keywords | generator, scaffold, scaffolding, yeoman, yeoman-generator |

## Links

- npm: https://www.npmjs.com/package/generator-yogini
- Repository: https://github.com/raineorshine/yogini
- Homepage: https://github.com/raineorshine/yogini#readme
- Issues: https://github.com/raineorshine/yogini/issues
- npm.io page: https://npm.io/package/generator-yogini

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.7.2
- [prefixnote](https://npm.io/package/prefixnote.md) ^3.0.0
- [gulp-striate](https://npm.io/package/gulp-striate.md) ^1.0.2
- [yeoman-generator](https://npm.io/package/yeoman-generator.md) git+https://github.com/raineorshine/generator.git#mem-fs-editor

## Recent versions

- 2.0.1 (latest) — 2021-01-23
- 2.0.0-alpha.1 (next) — 2021-01-23
- 2.0.0 — 2021-01-23
- 1.5.1 — 2020-11-17
- 1.5.0 — 2020-11-17
- 1.4.0 — 2020-11-17
- 1.3.0 — 2020-11-15

## README

# yogini
[![npm version](https://img.shields.io/npm/v/yogini.svg)](https://npmjs.org/package/yogini)

**yogini** is a prompt-driven scaffolding system. It makes it easy to create and maintain personal boilerplates that evolve over time.

What makes **yogini** different?

- Prompt-driven (via [Inquirer](https://github.com/SBoudrias/Inquirer.js)) with [easy prompt configuration](https://github.com/raineorshine/yogini/blob/master/app/yogini.json)
- Embedded file-copying logic, e.g. `{useSass}main.scss`
- Templating with [striate](https://github.com/raineorshine/striate), a superset of [ejs](https://github.com/mde/ejs) with better handling of multi-line blocks

Generators created by yogini are [yeoman](http://yeoman.io/) generators, so they can be published and consumed them like any other yeoman generator. You do not need to understand yeoman to use yogini.

## Install

```sh
npm install -g yo                 # install yeoman
npm install -g generator-yogini   # install yogini
```

## Quick Start

### 1. Create your generator

```sh
mkdir generator-mygen             # create a directory for your new generator
cd generator-mygen            
yo yogini                         # generate a blank yogini generator
npm link                          # alias your generator to your globally
                                  # installed npm modules so that you can run
                                  # it with yeoman.
```

### 2. Use your generator

```sh
mkdir mygen1                      # create a directory for your new project
cd mygen1
yo mygen                          # generate a new project
```

## Architecture

Would you like some generator with your generator? I know, it's a bit confusing. There are four levels to be aware of:

- **yo** - Ye ol' scaffolding framework. Does all the hard work, like a good yeoman. Kind of a pain to work with as a developer.
- **yogini** - Ye fancy `yo` wrapper that makes it easier to create, evolve, and maintain your generator.
- **generator-mygen** - Your personal generator. Name it whatever you want. Typically you'll have a single generator and use its powerful conditional prompts to control which files are copied for the desired project type.
- **mygen1** - A cute little offspring from `generator-mygen`. A fresh, new project!

## Building your generator

An initial **yogini** generator produces only a blank README, so you have to customize it to generate something useful.

- Drop files into `app/templates`. All files from this directory will be copied into your project directory when you run the generator.
- Edit the [Inquirer](https://github.com/SBoudrias/Inquirer.js) prompts in `app/yogini.json`. These will determine which files get copied (via [prefixnotes](https://github.com/raineorshine/prefixnote)) and what code gets copied (via [striate](https://github.com/raineorshine/striate)).

Sample yogini.json file:

```js
{
  "prompts": [
    {
      "type": "confirm",
      "name": "js",
      "message": "Does your project use Javascript?",
      "store": true
    },
    {
      "type": "confirm",
      "name": "css",
      "message": "Does your project use css?",
      "store": true
    }
  }
}
```

The above yogini.json file would prompt you with two questions every time you run your generator and store the answers in `js` and `css` variables. These variables drive the main two aspects of scaffolding: file copying and templating.

### 1. File Copying

You can control which files in `/app/templates` get copied into your new project by prefixing filenames with expressions that include prompt variables.

```
.
├── index.html
├── {js}scripts
│   └── main.js
└── {css}styles
    └── main.css
```

In the above example, the scripts folder will only be copied if `js` (as declared in yogini.json) is true, and the `styles` folder will only be copied if `css` is true.

- Empty expressions are a great way to include system and hidden files in your templates folder without them having an effect until they are copied:
  - `{}package.json`
  - `{}.gitignore`
- If a folder name only consists of an expression, all files will be copied to the parent folder:

  ```sh
  main.js
  {js}
    ├── 1.js
    ├── 2.js
    └── 3.js
  ```

  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⇨

  ```sh
  main.js
  1.js
  2.js
  3.js
  ```

- Expressions can be any Javascript expression that evaluates to `boolean`:

  ```sh
  {js && gulp}gulpfile.js
  ```

See [prefixnote](https://github.com/raineorshine/prefixnote) for the nitty-gritty.


### 2. Templating

You can use [striate](https://github.com/raineorshine/striate), a superset of [ejs](https://github.com/mde/ejs), to control which code gets generated within the files. The answers given to the prompts in yogini.json are available as variables within the scope of your template files.

```html
<!DOCTYPE html>
<html>
<head>
  >> if(css) {
  <link rel='Stylesheet' type='text/css' href='styles/main.css'>
  >> }
</head>
<body>
  >> if(js) {
  <script src='scripts/main.js'></script>
  >> }
</body>
</html>
```

You can see a complete yogini generator with prompts, file prefixes, and templating at [generator-yogini-sample](https://github.com/raineorshine/generator-yogini-sample).

## License

ISC © [Raine Revere](https://github.com/raineorshine)

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