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+
312Simple Scaffold allows you to generate any set of files in the easiest way possible with simple commands.
413
514It 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
5463npx 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
6275Usage: 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
109122You 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
121134You can also build the scaffold yourself, if you want to create more complex arguments or scaffold
122135groups - 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
219234Simple-Scaffold provides some built-in text transformation filters usable by handleBars.
220235
221236For example, you may use ` {{ snakeCase name }} ` inside a template file or filename, and it will
222237replace ` 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
270285You may also add your own custom helpers using the ` helpers ` options when using the JS API (rather
271286than 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
291308simple-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
314346import 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
349380import React from 'react'
0 commit comments