Skip to content

Commit bf10fb8

Browse files
committed
update docs
1 parent 4e2fa01 commit bf10fb8

7 files changed

Lines changed: 134 additions & 78 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ tab_width = 2
33
indent_style = space
44
insert_final_newline = true
55
trim_trailing_whitespace = true
6+
7+
[*.md]
8+
trim_trailing_whitespace = false

.github/workflows/develop.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ jobs:
1616
- run: yarn test
1717
- run: yarn build
1818
- run: cd ./dist && yarn pack --filename=../package.tgz
19-
if: "!contains(github.event.head_commit.message, '[skip publish]')"
19+
if: "contains(github.event.head_commit.message, '[publish]')"
2020
- uses: Klemensas/action-autotag@stable
21-
if: "!contains(github.event.head_commit.message, '[skip publish]')"
21+
if: "contains(github.event.head_commit.message, '[publish]')"
2222
id: update_tag
2323
with:
2424
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2525
tag_prefix: "v"
2626
- name: Publish on NPM
2727
uses: JS-DevTools/npm-publish@v1
28-
if: "!contains(github.event.head_commit.message, '[skip publish]')"
28+
if: "contains(github.event.head_commit.message, '[publish]')"
2929
with:
3030
package: ./dist/package.json
3131
token: "${{ secrets.NPM_TOKEN }}"
3232
- name: Create Release
33-
if: steps.update_tag.outputs.tagname && !contains(github.event.head_commit.message, '[skip publish]')
33+
if: steps.update_tag.outputs.tagname && contains(github.event.head_commit.message, '[publish]')
3434
uses: actions/create-release@v1
3535
id: create_release
3636
env:
@@ -40,7 +40,7 @@ jobs:
4040
tag_name: ${{ steps.update_tag.outputs.tagname }}
4141
release_name: Release ${{ steps.update_tag.outputs.tagname }}
4242
- name: Upload Release Asset
43-
if: steps.update_tag.outputs.tagname && !contains(github.event.head_commit.message, '[skip publish]')
43+
if: steps.update_tag.outputs.tagname && contains(github.event.head_commit.message, '[publish]')
4444
id: upload-release-asset
4545
uses: actions/upload-release-asset@v1
4646
env:

.markdownlint.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"MD013": {
2+
"line-length": {
33
"line_length": 100,
44
"tables": false,
55
"code_blocks": false
66
},
7-
"MD033": false
8-
}
7+
"no-inline-html": false,
8+
"first-line-h1": false
9+
}

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@
1010
"noext",
1111
"nonegate",
1212
"subdir"
13-
]
14-
}
13+
],
14+
"[markdown]": {
15+
"editor.rulers": [
16+
87,
17+
100
18+
],
19+
},
20+
}

.vscode/tasks.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"type": "npm",
1414
"problemMatcher": [],
1515
},
16+
{
17+
"command": "yarn typedoc --watch",
18+
"label": "typedoc --watch",
19+
"type": "shell",
20+
"problemMatcher": [],
21+
},
1622
{
1723
"script": "start",
1824
"label": "start",
@@ -50,4 +56,4 @@
5056
"problemMatcher": [],
5157
},
5258
],
53-
}
59+
}

README.md

Lines changed: 94 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
<div style="text-align:center;">
2+
13
# Simple Scaffold
24

5+
[GitHub](https://github.com/chenasraf/simple-scaffold) |
6+
[Documentation](https://casraf.blog/simple-scaffold) |
7+
[NPM](https://npmjs.com/package/simple-scaffold) |
8+
[casraf.blog](https://casraf.blog)
9+
10+
</div>
11+
312
Simple Scaffold allows you to generate any set of files in the easiest way possible with simple commands.
413

514
It is completely framework agnostic so you can use it for anything from a few simple files to an
@@ -16,25 +25,25 @@ other custom data) inside the paths or contents of the files using Handlebars.js
1625

1726
- [Simple Scaffold](#simple-scaffold)
1827
- [Install](#install)
19-
- [Use as a command line tool](#use-as-a-command-line-tool)
20-
- [Command Line Options](#command-line-options)
21-
- [Use in Node.js](#use-in-nodejs)
28+
- [Command Line Interface (CLI)](#command-line-interface-cli)
29+
- [Available flags](#available-flags)
30+
- [Node module](#node-module)
2231
- [Node-specific options](#node-specific-options)
2332
- [Preparing files](#preparing-files)
2433
- [Template files](#template-files)
2534
- [Variable/token replacement](#variabletoken-replacement)
26-
- [Built-in Helpers](#built-in-helpers)
27-
- [Capitalization Helpers](#capitalization-helpers)
28-
- [Date helpers](#date-helpers)
29-
- [Custom Helpers](#custom-helpers)
35+
- [Helpers](#helpers)
36+
- [Built-in Helpers](#built-in-helpers)
37+
- [Capitalization Helpers](#capitalization-helpers)
38+
- [Date helpers](#date-helpers)
39+
- [Custom Helpers](#custom-helpers)
3040
- [Examples](#examples)
31-
- [Command Example](#command-example)
32-
- [Example Scaffold Input](#example-scaffold-input)
33-
- [Input Directory structure](#input-directory-structure)
34-
- [Contents of `project/scaffold/{{Name}}.jsx`](#contents-of-projectscaffoldnamejsx)
35-
- [Example Scaffold Output](#example-scaffold-output)
36-
- [Output directory structure](#output-directory-structure)
37-
- [Contents of `project/scaffold/MyComponent/MyComponent.jsx`](#contents-of-projectscaffoldmycomponentmycomponentjsx)
41+
- [Run](#run)
42+
- [Command Example](#command-example)
43+
- [Node Module Example](#node-module-example)
44+
- [Files](#files)
45+
- [Input](#input)
46+
- [Output](#output)
3847
- [Contributing](#contributing)
3948

4049
</details>
@@ -54,9 +63,13 @@ yarn [global] add simple-scaffold
5463
npx simple-scaffold@latest <...args>
5564
```
5665

57-
## Use as a command line tool
66+
## Command Line Interface (CLI)
5867

59-
### Command Line Options
68+
### Available flags
69+
70+
The following is the help text from the `simple-scaffold` binary. To see this and more
71+
information anytime, add the `-h` or `--help` flag to your call, e.g.
72+
`npx simple-scaffold@latest -h`.
6073

6174
```plaintext
6275
Usage: simple-scaffold [options]
@@ -67,26 +80,26 @@ Options:
6780
6881
--help|-h Display help information
6982
70-
--name|-n Name to be passed to the generated files. {{name}} and
71-
{{Name}} inside contents and file names will be replaced
72-
accordingly.
83+
--name|-n Name to be passed to the generated files. {{name}}
84+
and {{Name}} inside contents and file names will be
85+
replaced accordingly.
7386
7487
--output|-o Path to output to. If --create-sub-folder is enabled,
7588
the subfolder will be created inside this path.
7689
(default: current dir)
7790
78-
--templates|-t Template files to use as input. You may provide multiple
79-
files, each of which can be a relative or absolute path, or a
80-
glob pattern for multiple file matching easily.
91+
--templates|-t Template files to use as input. You may provide
92+
multiple files, each of which can be a relative or
93+
absolute path, or a glob pattern for multiple file
94+
matching easily.
8195
8296
--overwrite|-w Enable to override output files, even if they already
8397
exist. (default: false)
8498
85-
--data|-d Add custom data to the templates. By default, only your
86-
app name is included.
99+
--data|-d Add custom data to the templates. By default, only
100+
your app name is included.
87101
88-
--create-sub-folder|-s Create subfolder with the input name
89-
(default: false)
102+
--create-sub-folder|-s Create subfolder with the input name (default: false)
90103
91104
--sub-folder-name-helper|-sh Default helper to apply to subfolder name when using
92105
`--create-sub-folder true`.
@@ -101,9 +114,9 @@ Options:
101114
2)
102115
103116
--dry-run|-dr Don't emit files. This is good for testing your
104-
scaffolds and making sure they don't fail, without having to
105-
write actual file contents or create directories.
106-
(default: false)
117+
scaffolds and making sure they don't fail, without
118+
having to write actual file contents or create
119+
directories. (default: false)
107120
```
108121

109122
You can also add this as a script in your `package.json`:
@@ -116,7 +129,7 @@ You can also add this as a script in your `package.json`:
116129
}
117130
```
118131

119-
## Use in Node.js
132+
## Node module
120133

121134
You can also build the scaffold yourself, if you want to create more complex arguments or scaffold
122135
groups - simply pass a config object to the Scaffold function when you are ready to start.
@@ -214,14 +227,16 @@ Your `data` will be pre-populated with the following:
214227
> [Handlebars.js Language Features](https://handlebarsjs.com/guide/#language-features) for more
215228
> information.
216229
217-
### Built-in Helpers
230+
### Helpers
231+
232+
#### Built-in Helpers
218233

219234
Simple-Scaffold provides some built-in text transformation filters usable by handleBars.
220235

221236
For example, you may use `{{ snakeCase name }}` inside a template file or filename, and it will
222237
replace `My Name` with `my_name` when producing the final value.
223238

224-
#### Capitalization Helpers
239+
##### Capitalization Helpers
225240

226241
| Helper name | Example code | Example output |
227242
| ------------ | ----------------------- | -------------- |
@@ -235,7 +250,7 @@ replace `My Name` with `my_name` when producing the final value.
235250
| `upperCase` | `{{ upperCase name }}` | MY NAME |
236251
| `lowerCase` | `{{ lowerCase name }}` | my name |
237252

238-
#### Date helpers
253+
##### Date helpers
239254

240255
| Helper name | Description | Example code | Example output |
241256
| -------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------ |
@@ -265,7 +280,7 @@ Further details:
265280
- **The now helper** (for current time) takes the same arguments, minus the first one (`date`) as
266281
it is implicitly the current date.
267282

268-
### Custom Helpers
283+
#### Custom Helpers
269284

270285
You may also add your own custom helpers using the `helpers` options when using the JS API (rather
271286
than the CLI). The `helpers` option takes an object whose keys are helper names, and values are
@@ -285,7 +300,9 @@ All of the above helpers (built in and custom) will also be available to you whe
285300

286301
## Examples
287302

288-
### Command Example
303+
### Run
304+
305+
#### Command Example
289306

290307
```bash
291308
simple-scaffold MyComponent \
@@ -295,20 +312,35 @@ simple-scaffold MyComponent \
295312
MyComponent
296313
```
297314

298-
### Example Scaffold Input
315+
#### Node Module Example
299316

300-
#### Input Directory structure
317+
```typescript
318+
import Scaffold from 'simple-scaffold';
319+
320+
async function main() {
321+
await Scaffold({
322+
name: 'MyComponent',
323+
templates: ['project/scaffold/**/*'],
324+
output: ['src/components'],
325+
data: {
326+
className: 'myClassName',
327+
},
328+
});
329+
console.log('Done.');
330+
}
331+
```
332+
333+
### Files
334+
335+
#### Input
336+
337+
Input file path:
301338

302339
```plaintext
303-
- project
304-
- scaffold
305-
- {{Name}}.js
306-
- src
307-
- components
308-
- ...
340+
project → scaffold → {{Name}}.js → src → components
309341
```
310342

311-
#### Contents of `project/scaffold/{{Name}}.jsx`
343+
Input file contents:
312344

313345
```typescript
314346
import React from 'react'
@@ -320,30 +352,29 @@ export default {{camelCase name}}: React.FC = (props) => {
320352
}
321353
```
322354

323-
### Example Scaffold Output
355+
#### Output
324356

325-
### Output directory structure
357+
Output file path:
326358

327-
```plaintext
328-
- project
329-
- src
330-
- components
331-
- MyComponent
332-
- MyComponent.js
333-
- ...
334-
```
359+
- With `createSubFolder = false` (default):
335360

336-
With `createSubFolder = false`:
361+
```plaintext
362+
project → src → components → MyComponent.js
363+
```
337364

338-
```plaintext
339-
- project
340-
- src
341-
- components
342-
- MyComponent.js
343-
- ...
344-
```
365+
- With `createSubFolder = true`:
366+
367+
```plaintext
368+
project → src → components → MyComponent → MyComponent.js
369+
```
370+
371+
- With `createSubFolder = true` and `subFolderNameHelper = 'upperCase'`:
372+
373+
```plaintext
374+
project → src → components → MYCOMPONENT → MyComponent.js
375+
```
345376

346-
#### Contents of `project/scaffold/MyComponent/MyComponent.jsx`
377+
Output file contents:
347378

348379
```typescript
349380
import React from 'react'

0 commit comments

Comments
 (0)