# create-whatever

> create 'create-' app

Latest version **5.5.0** (published 2020-06-27) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install create-whatever
pnpm add create-whatever
yarn add create-whatever
bun add create-whatever
```

Provides the command `create-whatever`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.5.0 |
| Published | 2020-06-27 |
| First published | 2019-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 57.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 102 |
| Author | Yasuaki Uechi |
| Maintainers | uetchy |
| Keywords | create-whatever |

## Links

- npm: https://www.npmjs.com/package/create-whatever
- Repository: https://github.com/uetchy/create-whatever
- Issues: https://github.com/uetchy/create-whatever/issues
- npm.io page: https://npm.io/package/create-whatever

## Dependencies (13)

- [uuid](https://npm.io/package/uuid.md) ^8.2.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [execa](https://npm.io/package/execa.md) ^4.0.2
- [globby](https://npm.io/package/globby.md) ^11.0.1
- [is-utf8](https://npm.io/package/is-utf8.md) ^0.2.1
- [inquirer](https://npm.io/package/inquirer.md) ^7.2.0
- [gitconfig](https://npm.io/package/gitconfig.md) ^2.0.8
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.6
- [license.js](https://npm.io/package/license.js.md) ^3.1.2
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3
- [@types/inquirer](https://npm.io/package/@types/inquirer.md) ^6.5.0
- [yargs-interactive](https://npm.io/package/yargs-interactive.md) ^3.0.0
- [@types/yargs-interactive](https://npm.io/package/@types/yargs-interactive.md) ^2.1.0

## Recent versions

- 5.5.0 (latest) — 2020-06-27
- 5.4.0 — 2020-06-27
- 5.3.0 — 2020-06-26
- 5.2.1 — 2020-06-26
- 5.2.0 — 2020-06-26
- 5.1.1 — 2020-06-26
- 5.1.0 — 2020-06-26
- 5.0.1 — 2020-06-24
- 5.0.0 — 2019-10-09
- 4.1.0 — 2019-10-09
- 4.0.4 — 2019-10-09
- 4.0.3 — 2019-10-08
- 4.0.0 — 2019-10-08
- 3.1.0 — 2019-10-08
- 3.0.1 — 2019-10-07
- … 10 more at https://npm.io/package/create-whatever/versions

## README

# ✨ Create Whatever

[![npm-badge]][npm-url] [![workflow-badge]][workflow-url]

[npm-badge]: https://img.shields.io/npm/v/create-whatever.svg
[npm-url]: https://npmjs.org/package/create-whatever
[workflow-badge]: https://github.com/uetchy/create-whatever/workflows/create-whatever/badge.svg
[workflow-url]: https://github.com/uetchy/create-whatever/actions?workflow=create-whatever

> The smartest `create-` app template generator.

![screencast](https://raw.githubusercontent.com/uetchy/create-whatever/master/.github/assets/screencast.gif)

## Why?

- ⚖️ **Built-in License chooser** No need to care about license things.
- 🎩 **Template engine** Just put files with template strings and we will do the rest.
- 💄 **Highly customizable** Can change caveat text, and add extra cli options.

## Table of contents

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Quick Start](#quick-start)
  - [1. `yarn create whatever`](#1-yarn-create-whatever)
  - [2. Edit templates](#2-edit-templates)
    - [TypeScript](#typescript)
  - [3. Publish package to npm](#3-publish-package-to-npm)
  - [4. PROFIT!](#4-profit)
- [Template](#template)
  - [Helper functions](#helper-functions)
    - [`upper`](#upper)
    - [`lower`](#lower)
    - [`camel`](#camel)
    - [`capital`](#capital)
    - [`snake`](#snake)
    - [`kebab`](#kebab)
    - [`uuid`](#uuid)
- [Config](#config)
  - [`extra`](#extra)
  - [`caveat`](#caveat)
    - [AfterHookOptions](#afterhookoptions)
  - [`after`](#after)
- [Contribution](#contribution)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Quick Start

Let's create `create-greet` package in four steps.

### 1. `yarn create whatever`

```shell
yarn create whatever create-greet --template typescript
```

or if you use `npm`, then run `npm create create-greet`

### 2. Edit templates

`cd create-greet` and edit files inside `templates/default`.

#### TypeScript

Run `yarn build` or `npm run build` to transpile TypeScript into JavaScript.

### 3. Publish package to npm

Run `yarn publish` or `npm publish` to publish your `create-` app to npm.

### 4. PROFIT!

```bash
yarn create greet ohayo
```

## Template

Edit files inside `templates/default`. File names, directory names, and text files will be processed through Handlebars template engine to replace all template strings with respective value.

- `{{name}}` package name
- `{{description}}` package description
- `{{author}}` author name
- `{{email}}` author email
- `{{contact}}` author name formatted with `{{name}} <{{email}}>` if email given, otherwise `{{name}}`
- `{{license}}` package license (e.g. `MIT`)
- `{{year}}` current year (e.g. `2020`)

### Helper functions

#### `upper`

Output text in UPPERCASE.

`{{upper name}}` becomes `CREATE-REACT-APP`.

#### `lower`

Output text in lowercase.

`{{lower name}}` becomes `create-react-app`.

#### `camel`

Output text in camelCase.

`{{camel name}}` becomes `createReactApp`.

#### `capital`

Output text in CapitalCase.

`{{capital name}}` becomes `CreateReactApp`, and `{{capital name space=true}}` becomes `Create React App`.

#### `snake`

Output text in snake_case.

`{{snake name}}` becomes `create_react_app`.

#### `kebab`

Output text in kebab-case.

`{{kebab name}}` becomes `create-react-app`.

#### `uuid`

Generates unique UUID string.

```
{{uuid}}
{{upper (uuid)}}
```

## Config

You can find the app config in `src/cli.ts`.

```ts
import {resolve} from 'path';
import {create} from 'create-whatever';

create('create-greet', {
  templateRoot: resolve(__dirname, '../templates'),
  extra: {
    language: {
      type: 'input',
      describe: 'greeting language',
      default: 'en',
      prompt: 'if-no-arg',
    },
  },
  caveat: `Your app has been created successfuly!`,
});
```

`templateRoot` set to `path.resolve(__dirname, '../templates')`. You can change it to whereever you want.

### `extra`

`object | undefined`

Extra options passed to the app. These options will be accessible as a cli option, interactive question, and template string. In this case, `--language` cli option and `{{language}}` template string will be available.

You can find all possible options in [yargs-interactive documentation](https://github.com/nanovazquez/yargs-interactive#options).

### `caveat`

`string | ((options: AfterHookOptions) => string | void) | undefined`

The caveat message will be shown after the entire process completed.

```js
create('create-greet', {
  caveat: 'Happy coding!',
});
```

```js
create('create-greet', {
  caveat: ({ answers }) => `Run -> cd ${answers.name} && make`,
});
```

```js
create('create-greet', {
  caveat: async ({ answers }) => {
    const pkg = answers.plugin;
    await execa('yarn', ['add', plugin]);
    console.log(`${plugin} has been added`);
  },
});
```

#### AfterHookOptions

```typescript
{
  // variables
  packageDir: string;
  templateDir: string;
  year: number; // 2020
  answers: {
    name: string; // package name
    description: string; // description
    author: string; // John Doe
    email: string; // john@example.com
    contact: string; // John Doe <john@example.com>
    license: string; // MIT
    [key: string]: string | number | boolean | any[]; // any values defined in the `extra` field.
  };
  // functions
  run: (command: string, options?: CommonOptions<string>) => ExecaChildProcess<string>; // run shell command in the package dir
  installNpmPackage: (packageName: string) => Promise<void>; // use yarn if available
}
```

### `after`

`(options: AfterHookOptions) => void`

After hook script that runs after the initialization.

## Contribution

PRs are always welcome!

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