UNPKG

1.49 kBMarkdownView Raw
1[![Build Status](https://travis-ci.org/philcockfield/new-file.svg?branch=master)](https://travis-ci.org/philcockfield/new-file)
2
3![Title](https://cloud.githubusercontent.com/assets/185555/25560728/018b33d8-2db0-11e7-8f37-2e1f7ba6e8a6.png)
4
5Super simple file templates, no fuss, just the way you like them.
6
7![Video](https://user-images.githubusercontent.com/185555/41954049-3f4e20f2-7a2d-11e8-92a1-8b6cc2a6950d.gif)
8
9## Install
10
11 npm install -g new-file
12
13## .template.yml
14
15Create folders that contain the files that make up your template.
16
17Include a `.template.yml` file within the folder defining the template and `variable` parameters to insert into the files:
18
19```yaml
20# .template.yml
21
22name: React Component (TSX)
23folder: NAME
24install: true # Optionally `{yarn|npm} install` on the folder (default: false).
25variables:
26 NAME: Component name
27 DESCRIPTION: Description
28 NAMESPACE: Storybook namespace
29```
30
31The folder `NAME` is taken as a parameter from the command line. Each variable key (eg `NAME`, `DESCRIPTION`, `NAMESPACE`) is inserted into the files where the variable name is surrunded by double `__`, eg:
32
33```tsx
34export class __NAME__ extends React.Component<I__NAME__Props> {
35 public render() {
36 return <div>__NAME__</div>;
37 }
38}
39```
40
41## .templates.yml
42
43Place an index in some containing folder where want the templates to be accessible via the command-line from, eg:
44
45```yaml
46# .templates.yml
47
48templateDirs:
49 - code/templates/*/
50 - helpers/my-other-templates/*/
51```