You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
91
99
92
100
Built-in variables are:
93
101
94
-
-`{{name}}` package name
102
+
-`{{name}}` package name (e.g. `ohayo`)
95
103
-`{{description}}` package description
96
-
-`{{author}}` author name
97
-
-`{{email}}` author email
98
-
-`{{contact}}` author name formatted with `{{name}} <{{email}}>` if email given, otherwise`{{name}}`
-`{{contact}}` author name formatted with `{{name}} <{{email}}>`. If email is missing, simply`{{name}}`
99
107
-`{{license}}` package license (e.g. `MIT`)
100
-
-`{{year}}` current year (e.g. `2020`)
108
+
-`{{year}}` current year (e.g. `2021`)
101
109
102
-
### Adding a template
110
+
### Advanced: Multiple templates
103
111
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.
106
114
107
115
### Helper functions
108
116
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`.
110
118
111
119
#### `upper`
112
120
113
-
Output text in UPPERCASE.
121
+
Convert text to UPPERCASE.
114
122
115
123
`{{upper name}}` becomes `CREATE-REACT-APP`.
116
124
117
125
#### `lower`
118
126
119
-
Output text in lowercase.
127
+
Convert text to lowercase.
120
128
121
129
`{{lower name}}` becomes `create-react-app`.
122
130
123
131
#### `capital`
124
132
125
-
Output text in CapitalCase.
133
+
Convert text to CapitalCase.
126
134
127
135
-`{{capital name}}` becomes `CreateReactApp`
128
136
-`{{capital name space=true}}` becomes `Create React App`.
129
137
130
138
#### `camel`
131
139
132
-
Output text in camelCase.
140
+
Convert text to camelCase.
133
141
134
142
`{{camel name}}` becomes `createReactApp`.
135
143
136
144
#### `snake`
137
145
138
-
Output text in snake_case.
146
+
Convert text to snake_case.
139
147
140
148
`{{snake name}}` becomes `create_react_app`.
141
149
142
150
#### `kebab`
143
151
144
-
Output text in kebab-case.
152
+
Convert text to kebab-case.
145
153
146
154
`{{kebab name}}` becomes `create-react-app`.
147
155
@@ -162,7 +170,7 @@ Generates unique UUID string.
162
170
163
171
## Config
164
172
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).
166
174
167
175
```ts
168
176
import { resolve } from'path';
@@ -186,13 +194,16 @@ create('create-greet', {
186
194
187
195
### templateRoot (required)
188
196
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.
190
198
191
199
### promptForTemplate (default: `false`)
192
200
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.
194
205
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 commandline flag `--template <template>`.
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.
206
217
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).
208
219
209
220
### modifyName (default: `undefined`)
210
221
211
222
`(name: string) => string | Promise<string>`
212
223
213
224
Modify `name` property.
214
225
226
+
```js
227
+
{
228
+
modifyName: (name) => (name.startsWith('create-') ? name :`create-${name}`);
229
+
}
230
+
```
231
+
215
232
### after (default: `undefined`)
216
233
217
234
`(options: AfterHookOptions) => void`
218
235
219
-
After hook script that runs after the initialization.
236
+
Define after-hook script to be executed after initialization.
-[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.
0 commit comments