Skip to content

Commit cf0df32

Browse files
committed
docs: fix typo
1 parent fead12f commit cf0df32

File tree

1 file changed

+89
-59
lines changed

1 file changed

+89
-59
lines changed

README.md

Lines changed: 89 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111

1212
## Why?
1313

14-
- ⚖️ **Built-in License chooser** No need to care about license things.
15-
- 🎩 **Template engine** Just put files with template strings and we will do the rest.
16-
- 💄 **Highly customizable** Can change caveat text, and add extra cli options.
14+
- ⚖️ **Built-in License chooser** No need to worry about license thingy.
15+
- 🎩 **Template engine** You can use template strings in text files, file names, and folder names.
16+
- 💄 **Highly customizable** Can change caveat text, add extra command-line options.
1717

1818
## Table of contents
1919

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

2323
- [Quick Start](#quick-start)
24-
- [1. `npm create create-app`](#1-npm-create-create-app)
25-
- [2. Edit templates](#2-edit-templates)
26-
- [TypeScript](#typescript)
27-
- [3. Publish package to npm](#3-publish-package-to-npm)
28-
- [4. PROFIT!](#4-profit)
24+
- [1. Bootstrap your project](#1-bootstrap-your-project)
25+
- [2. Add and edit template files](#2-add-and-edit-template-files)
26+
- [3. Build the app (TypeScript only)](#3-build-the-app-typescript-only)
27+
- [4. Publish package to npm](#4-publish-package-to-npm)
28+
- [5. PROFIT](#5-profit)
2929
- [Template](#template)
30-
- [Adding a template](#adding-a-template)
30+
- [Advanced: Multiple templates](#advanced-multiple-templates)
3131
- [Helper functions](#helper-functions)
3232
- [`upper`](#upper)
3333
- [`lower`](#lower)
@@ -53,95 +53,103 @@
5353

5454
## Quick Start
5555

56-
Let's create `create-greet` package in four steps.
56+
Let's create `create-greet` package in five steps.
5757

58-
### 1. `npm create create-app`
58+
### 1. Bootstrap your project
5959

6060
```shell
61-
npm create create-app greet
61+
npx create-create-app greet # simplest route
62+
npm init create-app greet # requires npm 6+
63+
yarn create create-app greet # requires Yarn 0.25+
6264
```
6365

64-
or if you use `yarn`, then run `yarn create create-app greet`
66+
You will then be asked about your project.
6567

6668
![screenshot](https://raw.githubusercontent.com/uetchy/create-create-app/master/.github/assets/ss1.png)
6769

68-
### 2. Edit templates
70+
### 2. Add and edit template files
6971

70-
`cd create-greet` and edit files inside `templates/default`.
72+
```shell
73+
cd create-greet
74+
```
7175

72-
#### TypeScript
76+
Then you can see the `templates/default` folder where the actual template files go.
7377

74-
Run `npm run build` or `yarn build` to transpile TypeScript code into JavaScript.
78+
### 3. Build the app (TypeScript only)
7579

76-
### 3. Publish package to npm
80+
Run `npm run build` or `yarn build` to transpile TypeScript code into JavaScript. If you chose the default template, this step is not necessary.
81+
82+
### 4. Publish package to npm
7783

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

80-
### 4. PROFIT!
86+
### 5. PROFIT
8187

8288
```bash
83-
npm create greet ohayo
89+
npx create-greet ohayo
90+
npm init greet ohayo
91+
yarn create greet ohayo
8492
```
8593

8694
![screenshot](https://raw.githubusercontent.com/uetchy/create-create-app/master/.github/assets/ss2.png)
8795

8896
## Template
8997

90-
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.
98+
Edit files inside `templates/default`. Every file name, directory name, and a text file will be processed through Handlebars template engine to replace all template strings with the respective value.
9199

92100
Built-in variables are:
93101

94-
- `{{name}}` package name
102+
- `{{name}}` package name (e.g. `ohayo`)
95103
- `{{description}}` package description
96-
- `{{author}}` author name
97-
- `{{email}}` author email
98-
- `{{contact}}` author name formatted with `{{name}} <{{email}}>` if email given, otherwise `{{name}}`
104+
- `{{author}}` author name (e.g. `John Doe`)
105+
- `{{email}}` author email (e.g. `[email protected]`)
106+
- `{{contact}}` author name formatted with `{{name}} <{{email}}>`. If email is missing, simply `{{name}}`
99107
- `{{license}}` package license (e.g. `MIT`)
100-
- `{{year}}` current year (e.g. `2020`)
108+
- `{{year}}` current year (e.g. `2021`)
101109

102-
### Adding a template
110+
### Advanced: Multiple templates
103111

104-
Add new directory to the location defined in `templateRoot`; it will be accessible in `--template` flag (e.g. `create-something <name> --template <template>`).
105-
Besides, set `promptForTemplate` true to explicitly ask users to pick a template in initialization phase, otherwise `default` will be used.
112+
Creates a new directory in the location defined by `templateRoot`. It can be accessed via `--template` flag (e.g. `create-something <name> --template <template>`).
113+
You might want to set `promptForTemplate` to `true` to explicitly ask the user to choose a template during the initialization phase. If `promptForTemplate` is `false`, which is the default behavior, `default` template will be used unless the user explicitly selects a template via `--template` cli flag.
106114

107115
### Helper functions
108116

109-
In the following example, we assume that variable `name` is `create-react-app`.
117+
In the following example, we assume that the variable `name` is `create-react-app`.
110118

111119
#### `upper`
112120

113-
Output text in UPPERCASE.
121+
Convert text to UPPERCASE.
114122

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

117125
#### `lower`
118126

119-
Output text in lowercase.
127+
Convert text to lowercase.
120128

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

123131
#### `capital`
124132

125-
Output text in CapitalCase.
133+
Convert text to CapitalCase.
126134

127135
- `{{capital name}}` becomes `CreateReactApp`
128136
- `{{capital name space=true}}` becomes `Create React App`.
129137

130138
#### `camel`
131139

132-
Output text in camelCase.
140+
Convert text to camelCase.
133141

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

136144
#### `snake`
137145

138-
Output text in snake_case.
146+
Convert text to snake_case.
139147

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

142150
#### `kebab`
143151

144-
Output text in kebab-case.
152+
Convert text to kebab-case.
145153

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

@@ -162,7 +170,7 @@ Generates unique UUID string.
162170

163171
## Config
164172

165-
You can find the app config in `src/cli.js` (or `src/cli.ts` if you chose `typescript` template).
173+
The app configuration can be found in `src/cli.js` (or `src/cli.ts` if you choose the `typescript` template).
166174

167175
```ts
168176
import { resolve } from 'path';
@@ -186,13 +194,16 @@ create('create-greet', {
186194

187195
### templateRoot (required)
188196

189-
`templateRoot` set to `path.resolve(__dirname, '../templates')`. You can change it to whereever you want.
197+
`templateRoot` is set to `path.resolve(__dirname, '../templates')`. You can change this to any location you like.
190198

191199
### promptForTemplate (default: `false`)
192200

193-
Ask users to choose a template to be used for initialization only if `promptForTemplate` is set `true` AND there's multiple templates found in `templates/`.
201+
Interactively asks the user to select a template if and only if:
202+
203+
1. `promptForTemplate` is set to `true`, and
204+
2. there are multiple templates in the `templates` directory.
194205

195-
With `promptForTemplate` set `false`, users still can specify template via command-line flag `--template`:
206+
Even if `promptForTemplate` is set to `false`, the user can still specify a template with the command line flag `--template <template>`.
196207

197208
```
198209
create-something <name> --template <template>
@@ -202,27 +213,33 @@ create-something <name> --template <template>
202213

203214
`object | undefined`
204215

205-
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.
216+
Additional questions can be defined. These options will be available as CLI flags, interactive questions, and template strings. In the example above, `--language` flag and the `{{language}}` template string will be enabled in the app.
206217

207-
You can find all possible options in [yargs-interactive documentation](https://github.com/nanovazquez/yargs-interactive#options).
218+
All possible options can be found in the [yargs-interactive documentation](https://github.com/nanovazquez/yargs-interactive#options).
208219

209220
### modifyName (default: `undefined`)
210221

211222
`(name: string) => string | Promise<string>`
212223

213224
Modify `name` property.
214225

226+
```js
227+
{
228+
modifyName: (name) => (name.startsWith('create-') ? name : `create-${name}`);
229+
}
230+
```
231+
215232
### after (default: `undefined`)
216233

217234
`(options: AfterHookOptions) => void`
218235

219-
After hook script that runs after the initialization.
236+
Define after-hook script to be executed after initialization.
220237

221238
### caveat (default: `undefined`)
222239

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

225-
The caveat message will be shown after the entire process completed.
242+
The caveat message will be shown after the entire process is completed.
226243

227244
```js
228245
create('create-greet', {
@@ -238,9 +255,17 @@ create('create-greet', {
238255

239256
```js
240257
create('create-greet', {
258+
extra: {
259+
plugin: {
260+
type: 'input',
261+
describe: 'plugin to be used in your project',
262+
default: 'some-plugin',
263+
prompt: 'if-no-arg',
264+
},
265+
},
241266
caveat: async ({ answers }) => {
242-
const pkg = answers.plugin;
243-
await execa('yarn', ['add', plugin]);
267+
const plugin = answers.plugin;
268+
await execa('npm', ['install', '-S', plugin]);
244269
console.log(`${plugin} has been added`);
245270
},
246271
});
@@ -251,36 +276,41 @@ create('create-greet', {
251276
```typescript
252277
{
253278
// variables
254-
packageDir: string;
255-
templateDir: string;
256-
year: number; // 2020
279+
packageDir: string; // e.g. "/path/to/ohayo"
280+
templateDir: string; // e.g. "/path/to/create-greet/templates/default"
281+
year: number; // e.g. 2020
257282
answers: {
258-
name: string; // package name
283+
name: string; // package name passed through `modifyName`
259284
description: string; // description
260-
author: string; // John Doe
261-
email: string; // [email protected]
262-
contact: string; // John Doe <[email protected]>
263-
license: string; // MIT
285+
author: string; // e.g. "John Doe"
286+
email: string; // e.g. "[email protected]"
287+
contact: string; // e.g. "John Doe <[email protected]>"
288+
license: string; // e.g. "MIT"
264289
[key: string]: string | number | boolean | any[]; // any values defined in the `extra` field.
265290
};
266-
// functions
267-
run: (command: string, options?: CommonOptions<string>) => ExecaChildProcess<string>; // run shell command in the package dir
268-
installNpmPackage: (packageName: string) => Promise<void>; // use yarn if available
291+
292+
// helper functions
293+
run: (command: string, options?: CommonOptions<string>) => ExecaChildProcess<string>; // execute shell commands in the package dir
294+
installNpmPackage: (packageName: string) => Promise<void>; // install npm package. uses yarn if available
269295
}
270296
```
271297

272298
## Showcase
273299

274-
List of amazing projects built on `create-create-app`.
300+
List of amazing projects built with `create-create-app`.
275301

276302
- [create-create-app](https://github.com/uetchy/create-create-app) - Yes, `create-create-app` uses `create-create-app` itself to generate `create-<app>` template!
277303
- [create-book](https://github.com/vivliostyle/create-book) - Fast & frictionless book template generator.
304+
- [create-vivliostyle-theme](https://github.com/vivliostyle/themes/tree/master/packages/create-vivliostyle-theme) - Create Vivliostyle theme at ease.
305+
- [create-alfred-workflow](https://github.com/uetchy/create-alfred-workflow) - Create Alfred Workflow.
306+
- [create-catalyst](https://github.com/dvalinotti/create-catalyst) - NPM create-app command for scaffolding a new Web Components project with GitHub's Catalyst.
307+
- [create-lit](https://github.com/litelement-dev/create-lit) - Create simple-starter-kit `lit` applications.
278308

279309
> Send a PR to add yours here!
280310
281311
## Contribution
282312

283-
PRs are always welcome!
313+
PRs are always welcome.
284314

285315
### Contributors ✨
286316

0 commit comments

Comments
 (0)