simple-scaffold 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ Steps to reproduce the behavior:
16
16
 
17
17
  1. Prepare templates:
18
18
 
19
- ```txt
19
+ ```text
20
20
  This is my {{ template }}
21
21
  ```
22
22
 
@@ -13,7 +13,7 @@ jobs:
13
13
  with:
14
14
  node-version: "18.x"
15
15
  - run: yarn install --frozen-lockfile
16
- - run: yarn typedoc
16
+ - run: yarn build-docs
17
17
  - uses: peaceiris/actions-gh-pages@v3
18
18
  with:
19
19
  github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -15,8 +15,6 @@ jobs:
15
15
  - run: yarn install --frozen-lockfile
16
16
  - run: yarn test
17
17
  - run: yarn build
18
- - run: cd ./dist && yarn pack --filename=../package.tgz
19
- if: "!contains(github.event.head_commit.message, '[skip publish]')"
20
18
  - run: yarn semantic-release
21
19
  if: "!contains(github.event.head_commit.message, '[skip publish]')"
22
20
  env:
package/CHANGELOG.md CHANGED
@@ -1,25 +1,44 @@
1
1
  # Change Log
2
2
 
3
- ## [1.2.0](https://github.com/chenasraf/simple-scaffold/compare/v1.1.4...v1.2.0) (2023-04-24)
3
+ ## [1.3.1](https://github.com/chenasraf/simple-scaffold/compare/v1.3.0...v1.3.1) (2023-04-28)
4
4
 
5
5
 
6
- ### Features
6
+ ### Bug Fixes
7
7
 
8
- * append-data cli flag ([3c5c2de](https://github.com/chenasraf/simple-scaffold/commit/3c5c2ded02f61ff086e81ea4a7f40529bdff1c9d))
8
+ * docs ([6e19a86](https://github.com/chenasraf/simple-scaffold/commit/6e19a86190dd924058a48448aa6463569ef1125f))
9
+ * remove old peer-dep ([c7e2ef8](https://github.com/chenasraf/simple-scaffold/commit/c7e2ef862cb658feb1071ac120b185d8b34d6dd3))
9
10
 
11
+ ## [1.3.0](https://github.com/chenasraf/simple-scaffold/compare/v1.2.0...v1.3.0) (2023-04-25)
12
+
13
+ ### Features
14
+
15
+ - load scaffold config from files
16
+ ([c398976](https://github.com/chenasraf/simple-scaffold/commit/c3989769fee445c9183ff5e5b3892c4e9fb66a9e))
10
17
 
11
18
  ### Bug Fixes
12
19
 
13
- * ci node version ([767d34c](https://github.com/chenasraf/simple-scaffold/commit/767d34c684516d4cea865b25e87c27c779bb79ce))
14
- * semantic-release build dir ([f7956dd](https://github.com/chenasraf/simple-scaffold/commit/f7956ddc786018905c48ccf1f21a3bb4657c3d75))
15
- * support quote wrapping in append-data ([4fecca8](https://github.com/chenasraf/simple-scaffold/commit/4fecca848347312d45d704f82f2bcb3822da9b06))
20
+ - config option should not be mandatory
21
+ ([3db6a91](https://github.com/chenasraf/simple-scaffold/commit/3db6a918f13d9300efa2fcb4a356d004475ab91c))
22
+ - export config file type
23
+ ([4302eb5](https://github.com/chenasraf/simple-scaffold/commit/4302eb5ce35ed6cf1dc80dfb92790c3fdd96f963))
16
24
 
17
- ### [1.1.4](https://github.com/chenasraf/simple-scaffold/compare/v1.1.3...v1.1.4) (2023-04-24)
25
+ ## [1.2.0](https://github.com/chenasraf/simple-scaffold/compare/v1.1.4...v1.2.0) (2023-04-24)
18
26
 
19
27
  ### Features
20
28
 
21
29
  - append-data cli flag
22
- ([2f4f7fc](https://github.com/chenasraf/simple-scaffold/commit/2f4f7fce47669e37ff49154fbec2acdfd0f5860e))
30
+ ([3c5c2de](https://github.com/chenasraf/simple-scaffold/commit/3c5c2ded02f61ff086e81ea4a7f40529bdff1c9d))
31
+
32
+ ### Bug Fixes
33
+
34
+ - ci node version
35
+ ([767d34c](https://github.com/chenasraf/simple-scaffold/commit/767d34c684516d4cea865b25e87c27c779bb79ce))
36
+ - semantic-release build dir
37
+ ([f7956dd](https://github.com/chenasraf/simple-scaffold/commit/f7956ddc786018905c48ccf1f21a3bb4657c3d75))
38
+ - support quote wrapping in append-data
39
+ ([4fecca8](https://github.com/chenasraf/simple-scaffold/commit/4fecca848347312d45d704f82f2bcb3822da9b06))
40
+
41
+ ## [1.1.4](https://github.com/chenasraf/simple-scaffold/compare/v1.1.3...v1.1.4) (2023-03-13)
23
42
 
24
43
  ### Bug Fixes
25
44
 
@@ -28,7 +47,16 @@
28
47
  - github action node version
29
48
  ([94fec76](https://github.com/chenasraf/simple-scaffold/commit/94fec766165f7540c578dbf2d0aeeb6ea3969ad8))
30
49
 
31
- ### [1.1.3](https://github.com/chenasraf/simple-scaffold/compare/v1.1.2...v1.1.3) (2023-03-11)
50
+ ### Misc
51
+
52
+ - update typedoc version
53
+ ([c334396](https://github.com/chenasraf/simple-scaffold/commit/c334396d74414cbe0aba305c66dfad7fdeb88669))
54
+ - update dependencies
55
+ ([20400bd](https://github.com/chenasraf/simple-scaffold/commit/20400bd81dd43d457427675286c9964a8bc0d5f6))
56
+ - bump version number
57
+ ([8e432bf](https://github.com/chenasraf/simple-scaffold/commit/8e432bfb0b410dc0655c3924031bea2648a42ad0))
58
+
59
+ ## [1.1.3](https://github.com/chenasraf/simple-scaffold/compare/v1.1.2...v1.1.3) (2023-03-11)
32
60
 
33
61
  ### Bug Fixes
34
62
 
@@ -39,19 +67,19 @@
39
67
 
40
68
  ## [1.1.0](https://github.com/chenasraf/simple-scaffold/compare/v1.0.4...v1.1.0) (2022-04-21)
41
69
 
42
- ### [1.0.3](https://github.com/chenasraf/simple-scaffold/compare/v1.0.2...v1.0.3) (2022-03-03)
70
+ ## [1.0.3](https://github.com/chenasraf/simple-scaffold/compare/v1.0.2...v1.0.3) (2022-03-03)
43
71
 
44
- ### [1.0.1-pre.1](https://github.com/chenasraf/simple-scaffold/compare/v1.0.0...v1.0.1-pre.1) (2022-02-17)
72
+ ## [1.0.1-pre.1](https://github.com/chenasraf/simple-scaffold/compare/v1.0.0...v1.0.1-pre.1) (2022-02-17)
45
73
 
46
- ### [0.7.5](https://github.com/chenasraf/simple-scaffold/compare/v0.7.4...v0.7.5) (2021-09-26)
74
+ ## [0.7.5](https://github.com/chenasraf/simple-scaffold/compare/v0.7.4...v0.7.5) (2021-09-26)
47
75
 
48
- ### [0.7.4](https://github.com/chenasraf/simple-scaffold/compare/v0.7.3...v0.7.4) (2021-09-26)
76
+ ## [0.7.4](https://github.com/chenasraf/simple-scaffold/compare/v0.7.3...v0.7.4) (2021-09-26)
49
77
 
50
- ### [0.7.3](https://github.com/chenasraf/simple-scaffold/compare/v0.7.2...v0.7.3) (2021-09-26)
78
+ ## [0.7.3](https://github.com/chenasraf/simple-scaffold/compare/v0.7.2...v0.7.3) (2021-09-26)
51
79
 
52
- ### [0.7.2](https://github.com/chenasraf/simple-scaffold/compare/v0.6.1...v0.7.2) (2021-04-19)
80
+ ## [0.7.2](https://github.com/chenasraf/simple-scaffold/compare/v0.6.1...v0.7.2) (2021-04-19)
53
81
 
54
- ### [0.6.1](https://github.com/chenasraf/simple-scaffold/compare/v0.6.0...v0.6.1) (2021-02-01)
82
+ ## [0.6.1](https://github.com/chenasraf/simple-scaffold/compare/v0.6.0...v0.6.1) (2021-02-01)
55
83
 
56
84
  ### Bug Fixes
57
85
 
@@ -67,26 +95,26 @@
67
95
 
68
96
  ## [0.5.0](https://github.com/chenasraf/simple-scaffold/compare/v0.4.5...v0.5.0) (2019-02-27)
69
97
 
70
- ### [0.4.5](https://github.com/chenasraf/simple-scaffold/compare/v0.4.4...v0.4.5) (2019-02-27)
98
+ ## [0.4.5](https://github.com/chenasraf/simple-scaffold/compare/v0.4.4...v0.4.5) (2019-02-27)
71
99
 
72
- ### [0.4.4](https://github.com/chenasraf/simple-scaffold/compare/v0.4.3...v0.4.4) (2019-02-27)
100
+ ## [0.4.4](https://github.com/chenasraf/simple-scaffold/compare/v0.4.3...v0.4.4) (2019-02-27)
73
101
 
74
- ### [0.4.3](https://github.com/chenasraf/simple-scaffold/compare/v0.4.2...v0.4.3) (2019-02-27)
102
+ ## [0.4.3](https://github.com/chenasraf/simple-scaffold/compare/v0.4.2...v0.4.3) (2019-02-27)
75
103
 
76
- ### [0.4.2](https://github.com/chenasraf/simple-scaffold/compare/v0.4.1...v0.4.2) (2019-02-25)
104
+ ## [0.4.2](https://github.com/chenasraf/simple-scaffold/compare/v0.4.1...v0.4.2) (2019-02-25)
77
105
 
78
- ### [0.4.1](https://github.com/chenasraf/simple-scaffold/compare/v0.3.1...v0.4.1) (2019-02-25)
106
+ ## [0.4.1](https://github.com/chenasraf/simple-scaffold/compare/v0.3.1...v0.4.1) (2019-02-25)
79
107
 
80
- ### [0.3.1](https://github.com/chenasraf/simple-scaffold/compare/v0.3.0...v0.3.1) (2018-01-15)
108
+ ## [0.3.1](https://github.com/chenasraf/simple-scaffold/compare/v0.3.0...v0.3.1) (2018-01-15)
81
109
 
82
110
  ## [0.3.0](https://github.com/chenasraf/simple-scaffold/compare/v0.2.0...v0.3.0) (2018-01-15)
83
111
 
84
112
  ## [0.2.0](https://github.com/chenasraf/simple-scaffold/compare/v0.1.5...v0.2.0) (2018-01-05)
85
113
 
86
- ### [0.1.5](https://github.com/chenasraf/simple-scaffold/compare/v0.1.4...v0.1.5) (2018-01-01)
114
+ ## [0.1.5](https://github.com/chenasraf/simple-scaffold/compare/v0.1.4...v0.1.5) (2018-01-01)
87
115
 
88
- ### [0.1.4](https://github.com/chenasraf/simple-scaffold/compare/v0.1.3...v0.1.4) (2018-01-01)
116
+ ## [0.1.4](https://github.com/chenasraf/simple-scaffold/compare/v0.1.3...v0.1.4) (2018-01-01)
89
117
 
90
- ### [0.1.3](https://github.com/chenasraf/simple-scaffold/compare/v0.1.2...v0.1.3) (2018-01-01)
118
+ ## [0.1.3](https://github.com/chenasraf/simple-scaffold/compare/v0.1.2...v0.1.3) (2018-01-01)
91
119
 
92
- ### 0.1.2 (2018-01-01)
120
+ ## 0.1.2 (2018-01-01)
package/README.md CHANGED
@@ -10,14 +10,18 @@
10
10
  ![build](https://img.shields.io/github/actions/workflow/status/chenasraf/simple-scaffold/release.yml?branch=master)
11
11
 
12
12
  </h2>
13
- Generate any set of files in the easiest way possible with simple commands.
14
13
 
15
- It is completely agnostic and un-opinionated so you can use it for anything from a few simple files
16
- to an entire app boilerplate setup.
14
+ Looking to streamline your workflow and get your projects up and running quickly? Look no further
15
+ than Simple Scaffold - the easy-to-use NPM package that simplifies the process of organizing and
16
+ copying your commonly-created files.
17
17
 
18
- Simply organize your commonly-created files in their **original structure**, and running Simple
19
- Scaffold will copy the files to the output path, while replacing values (such as component or app
20
- name, or other custom data) inside the paths or contents of the files using Handlebars.js syntax.
18
+ With its agnostic and un-opinionated approach, Simple Scaffold can handle anything from a few simple
19
+ files to an entire app boilerplate setup. Plus, with the power of **Handlebars.js** syntax, you can
20
+ easily replace custom data and personalize your files to fit your exact needs. But that's not all -
21
+ you can also use it to loop through data, use conditions, and write custom functions using helpers.
22
+
23
+ Don't waste any more time manually copying and pasting files - let Simple Scaffold do the heavy
24
+ lifting for you and start building your projects faster and more efficiently today!
21
25
 
22
26
  <div align="center">
23
27
 
@@ -25,385 +29,58 @@ name, or other custom data) inside the paths or contents of the files using Hand
25
29
 
26
30
  </div>
27
31
 
28
- <br />
29
-
30
- <details>
31
- <summary>Table of contents</summary>
32
-
33
- - [Install](#install)
34
- - [Command Line Interface (CLI)](#command-line-interface-cli)
35
- - [Available flags](#available-flags)
36
- - [Node module](#node-module)
37
- - [Node-specific options](#node-specific-options)
38
- - [Preparing files](#preparing-files)
39
- - [Template files](#template-files)
40
- - [Variable/token replacement](#variabletoken-replacement)
41
- - [Helpers](#helpers)
42
- - [Built-in Helpers](#built-in-helpers)
43
- - [Capitalization Helpers](#capitalization-helpers)
44
- - [Date helpers](#date-helpers)
45
- - [Custom Helpers](#custom-helpers)
46
- - [Examples](#examples)
47
- - [Run](#run)
48
- - [Command Example](#command-example)
49
- - [Equivalent Node Module Example](#equivalent-node-module-example)
50
- - [Files](#files)
51
- - [Input](#input)
52
- - [Output](#output)
53
- - [Contributing](#contributing)
54
-
55
- </details>
56
-
57
32
  ---
58
33
 
59
- ## Install
60
-
61
- You can either use it as a command line tool or import into your own code and run from there.
62
-
63
- ```bash
64
- # npm
65
- npm install [-g] simple-scaffold
66
- # yarn
67
- yarn [global] add simple-scaffold
68
- # run without installing
69
- npx simple-scaffold@latest <...args>
70
- ```
71
-
72
- ## Command Line Interface (CLI)
73
-
74
- ### Available flags
75
-
76
- The following is the help text from the `simple-scaffold` binary. To see this and more information
77
- anytime, add the `-h` or `--help` flag to your call, e.g. `npx simple-scaffold@latest -h`.
78
-
79
- ```text
80
- Usage: simple-scaffold [options]
81
-
82
- Create structured files based on templates.
83
-
84
- Options:
85
-
86
- --help|-h Display help information
87
-
88
- --name|-n Name to be passed to the generated files. {{name}}
89
- and {{Name}} inside contents and file names will be
90
- replaced accordingly.
91
-
92
- --output|-o Path to output to. If --create-sub-folder is enabled,
93
- the subfolder will be created inside this path.
94
- (default: current dir)
95
-
96
- --templates|-t Template files to use as input. You may provide
97
- multiple files, each of which can be a relative or
98
- absolute path, or a glob pattern for multiple file
99
- matching easily.
100
-
101
- --overwrite|-w Enable to override output files, even if they already
102
- exist. (default: false)
103
-
104
- --data|-d Add custom data to the templates. By default, only
105
- your app name is included.
106
-
107
- --append-data|-D Append additional custom data to the templates, which
108
- will overwrite --data, using an alternate syntax, which is
109
- easier to use with CLI: -D key1=string -D key2:=raw
110
-
111
- --create-sub-folder|-s Create subfolder with the input name (default: false)
112
-
113
- --sub-folder-name-helper|-sh Default helper to apply to subfolder name when using
114
- `--create-sub-folder true`.
115
-
116
- --quiet|-q Suppress output logs (Same as --verbose 0)
117
- (default: false)
34
+ ## Quick Start
118
35
 
119
- --verbose|-v Determine amount of logs to display. The values are:
120
- 0 (none) | 1 (debug) | 2 (info) | 3 (warn) | 4
121
- (error). The provided level will display messages of
122
- the same level or higher. (default:
123
- 2)
36
+ The fastest way to get started is to use `npx` to immediately start a scaffold process.
124
37
 
125
- --dry-run|-dr Don't emit files. This is good for testing your
126
- scaffolds and making sure they don't fail, without
127
- having to write actual file contents or create
128
- directories. (default: false)
129
- ```
38
+ Prepare any templates you want to use - for example, in the directory `templates/component`; and use
39
+ that in the CLI args. Here is a simple example file:
130
40
 
131
- You can also add this as a script in your `package.json`:
41
+ `templates/component/{{ pascalName name }}.tsx`
132
42
 
133
- ```json
134
- {
135
- "scripts": {
136
- "scaffold": "npx simple-scaffold@latest -t scaffolds/component/**/* -o src/components -d '{\"myProp\": \"propName\", \"myVal\": 123}'"
137
- }
138
- }
139
- ```
43
+ ```tsx
44
+ // Created: {{ now | 'yyyy-MM-dd' }}
45
+ import React from 'react'
140
46
 
141
- ## Node module
142
-
143
- You can also build the scaffold yourself, if you want to create more complex arguments or scaffold
144
- groups - simply pass a config object to the Scaffold function when you are ready to start.
145
-
146
- The config takes similar arguments to the command line:
147
-
148
- ```typescript
149
- import Scaffold from "simple-scaffold"
150
-
151
- const config = {
152
- name: "component",
153
- templates: [path.join(__dirname, "scaffolds", "component")],
154
- output: path.join(__dirname, "src", "components"),
155
- createSubFolder: true,
156
- subFolderNameHelper: "upperCase"
157
- data: {
158
- property: "value",
159
- },
160
- helpers: {
161
- twice: (text) => [text, text].join(" ")
162
- },
163
- beforeWrite: (content, rawContent, outputPath) => content.toString().toUpperCase()
47
+ export default {{pascalCase name}}: React.FC = (props) => {
48
+ return (
49
+ <div className="{{camelCase name}}">{{pascalCase name}} Component</div>
50
+ )
164
51
  }
165
-
166
- const scaffold = Scaffold(config)
167
52
  ```
168
53
 
169
- ### Node-specific options
170
-
171
- In addition to all the options available in the command line, there are some Node/JS-specific
172
- options available:
173
-
174
- | Option | Type | Description |
175
- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
176
- | `output` | | In addition to being passed the same as CLI, it may also be passed a function for each input file to output into a dynamic path: `{ output: (fullPath, baseDir, baseName) => path.resolve(baseDir, baseName) }` |
177
- | `helpers` | `Record<string, (string) => string>` | Helpers are simple functions that transform your `data` variables into other values. See [Helpers](#helpers) for the list of default helpers, or add your own to be loaded into the template parser. |
178
- | `beforeWrite` | `(content: Buffer, rawContent: Buffer, outputPath: string) => Promise<String \| Buffer \| undefined> \| String \| Buffer \| undefined` | Supply this function to override the final output contents of each of your files, allowing you to add more pre-processing to your generator pipeline. The return value of this function will replace the output content of the respective file, which you may discriminate (if needed) using the `outputPath` argument. |
179
- | `append-data` | | Does not exist in Node.JS options, use `data` instead. |
180
-
181
- ## Preparing files
182
-
183
- ### Template files
184
-
185
- Put your template files anywhere, and fill them with tokens for replacement.
186
-
187
- Each template (not file) in the config array is parsed individually, and copied to the output
188
- directory. If a single template path contains multiple files (e.g. if you use a folder path or a
189
- glob pattern), the first directory up the tree of that template will become the base inside the
190
- defined output path for that template, while copying files recursively and maintaining their
191
- relative structure.
54
+ To generate the template output, run:
192
55
 
193
- Examples:
194
-
195
- > In the following examples, the config `name` is `AppName`, and the config `output` is `src`.
196
-
197
- | Input template | Files in template | Output path(s) |
198
- | ----------------------------- | ------------------------------------------------------ | ------------------------------------------------------------ |
199
- | `./templates/{{ name }}.txt` | `./templates/{{ name }}.txt` | `src/AppName.txt` |
200
- | `./templates/directory` | `outer/{{name}}.txt`,<br />`outer2/inner/{{name}}.txt` | `src/outer/AppName.txt`,<br />`src/outer2/inner/AppName.txt` |
201
- | `./templates/others/**/*.txt` | `outer/{{name}}.jpg`,<br />`outer2/inner/{{name}}.txt` | `src/outer2/inner/AppName.txt` |
202
-
203
- ### Variable/token replacement
204
-
205
- Scaffolding will replace `{{ varName }}` in both the file name and its contents and put the
206
- transformed files in the output directory.
207
-
208
- The data available for the template parser is the data you pass to the `data` config option (or
209
- `--data` argument in CLI).
210
-
211
- For example, using the following command:
212
-
213
- ```bash
56
+ ```shell
57
+ # generate single component
214
58
  npx simple-scaffold@latest \
215
- --templates templates/components/{{name}}.jsx \
216
- --output src/components \
217
- --create-sub-folder true \
218
- MyComponent
219
- ```
220
-
221
- Will output a file with the path:
222
-
223
- ```text
224
- <working_dir>/src/components/MyComponent.jsx
59
+ -t templates/component -o src/components PageWrapper
225
60
  ```
226
61
 
227
- The contents of the file will be transformed in a similar fashion.
62
+ This will immediately create the following file: `src/components/PageWrapper.tsx`
228
63
 
229
- Your `data` will be pre-populated with the following:
64
+ ```tsx
65
+ // Created: 2077/01/01
66
+ import React from 'react'
230
67
 
231
- - `{{Name}}`: PascalCase of the component name
232
- - `{{name}}`: raw name of the component as you entered it
233
-
234
- > Simple-Scaffold uses [Handlebars.js](https://handlebarsjs.com/) for outputting the file contents.
235
- > Any `data` you add in the config will be available for use with their names wrapped in `{{` and
236
- > `}}`. Other Handlebars built-ins such as `each`, `if` and `with` are also supported, see
237
- > [Handlebars.js Language Features](https://handlebarsjs.com/guide/#language-features) for more
238
- > information.
239
-
240
- ### Helpers
241
-
242
- #### Built-in Helpers
243
-
244
- Simple-Scaffold provides some built-in text transformation filters usable by Handlebars.
245
-
246
- For example, you may use `{{ snakeCase name }}` inside a template file or filename, and it will
247
- replace `My Name` with `my_name` when producing the final value.
248
-
249
- ##### Capitalization Helpers
250
-
251
- | Helper name | Example code | Example output |
252
- | ------------ | ----------------------- | -------------- |
253
- | [None] | `{{ name }}` | my name |
254
- | `camelCase` | `{{ camelCase name }}` | myName |
255
- | `snakeCase` | `{{ snakeCase name }}` | my_name |
256
- | `startCase` | `{{ startCase name }}` | My Name |
257
- | `kebabCase` | `{{ kebabCase name }}` | my-name |
258
- | `hyphenCase` | `{{ hyphenCase name }}` | my-name |
259
- | `pascalCase` | `{{ pascalCase name }}` | MyName |
260
- | `upperCase` | `{{ upperCase name }}` | MY NAME |
261
- | `lowerCase` | `{{ lowerCase name }}` | my name |
262
-
263
- ##### Date helpers
264
-
265
- | Helper name | Description | Example code | Example output |
266
- | -------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------ |
267
- | `now` | Current date with format | `{{ now "yyyy-MM-dd HH:mm" }}` | `2042-01-01 15:00` |
268
- | `now` (with offset) | Current date with format, and with offset | `{{ now "yyyy-MM-dd HH:mm" -1 "hours" }}` | `2042-01-01 14:00` |
269
- | `date` | Custom date with format | `{{ date "2042-01-01T15:00:00Z" "yyyy-MM-dd HH:mm" }}` | `2042-01-01 15:00` |
270
- | `date` (with offset) | Custom date with format, and with offset | `{{ date "2042-01-01T15:00:00Z" "yyyy-MM-dd HH:mm" -1 "days" }}` | `2041-31-12 15:00` |
271
- | `date` (with date from `--data`) | Custom date with format, with data from the `data` config option | `{{ date myCustomDate "yyyy-MM-dd HH:mm" }}` | `2042-01-01 12:00` |
272
-
273
- Further details:
274
-
275
- - We use [`date-fns`](https://date-fns.org/docs/) for parsing/manipulating the dates. If you want
276
- more information on the date tokens to use, refer to
277
- [their format documentation](https://date-fns.org/docs/format).
278
-
279
- - The date helper format takes the following arguments:
280
-
281
- ```typescript
282
- (
283
- date: string,
284
- format: string,
285
- offsetAmount?: number,
286
- offsetType?: "years" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds"
68
+ export default PageWrapper: React.FC = (props) => {
69
+ return (
70
+ <div className="pageWrapper">PageWrapper Component</div>
287
71
  )
288
- ```
289
-
290
- - **The now helper** (for current time) takes the same arguments, minus the first one (`date`) as it
291
- is implicitly the current date.
292
-
293
- #### Custom Helpers
294
-
295
- You may also add your own custom helpers using the `helpers` options when using the JS API (rather
296
- than the CLI). The `helpers` option takes an object whose keys are helper names, and values are the
297
- transformation functions. For example, `upperCase` is implemented like so:
298
-
299
- ```typescript
300
- config.helpers = {
301
- upperCase: (text) => text.toUpperCase(),
302
- }
303
- ```
304
-
305
- All of the above helpers (built in and custom) will also be available to you when using
306
- `subFolderNameHelper` (`--sub-folder-name-helper`/`-sh`) as a possible value.
307
-
308
- > To see more information on how helpers work and more features, see
309
- > [Handlebars.js docs](https://handlebarsjs.com/guide/#custom-helpers).
310
-
311
- ## Examples
312
-
313
- ### Run
314
-
315
- #### Command Example
316
-
317
- ```bash
318
- simple-scaffold MyComponent \
319
- -t project/scaffold/**/* \
320
- -o src/components \
321
- -d '{"className": "myClassName","author": "Chen Asraf"}'
322
- MyComponent
323
- ```
324
-
325
- #### Equivalent Node Module Example
326
-
327
- ```typescript
328
- import Scaffold from "simple-scaffold"
329
-
330
- async function main() {
331
- await Scaffold({
332
- name: "MyComponent",
333
- templates: ["project/scaffold/**/*"],
334
- output: ["src/components"],
335
- data: {
336
- className: "myClassName",
337
- author: "Chen Asraf",
338
- },
339
- })
340
- console.log("Done.")
341
72
  }
342
73
  ```
343
74
 
344
- ### Files
345
-
346
- #### Input
347
-
348
- - Input file path:
349
-
350
- ```text
351
- project → scaffold → {{Name}}.js → src → components
352
- ```
353
-
354
- - Input file contents:
355
-
356
- ```typescript
357
- /**
358
- * Author: {{ author }}
359
- * Date: {{ now "yyyy-MM-dd" }}
360
- */
361
- import React from 'react'
362
-
363
- export default {{camelCase name}}: React.FC = (props) => {
364
- return (
365
- <div className="{{className}}">{{camelCase name}} Component</div>
366
- )
367
- }
368
- ```
369
-
370
- #### Output
371
-
372
- - Output file path:
373
-
374
- - With `createSubFolder = false` (default):
375
-
376
- ```text
377
- project → src → components → MyComponent.js
378
- ```
379
-
380
- - With `createSubFolder = true`:
381
-
382
- ```text
383
- project → src → components → MyComponent → MyComponent.js
384
- ```
385
-
386
- - With `createSubFolder = true` and `subFolderNameHelper = 'upperCase'`:
387
-
388
- ```text
389
- project → src → components → MYCOMPONENT → MyComponent.js
390
- ```
391
-
392
- - Output file contents:
75
+ ## Documentation
393
76
 
394
- ```typescript
395
- /**
396
- * Author: Chen Asraf
397
- * Date: 2022-01-01
398
- */
399
- import React from 'react'
77
+ See full documentation [here](https://chenasraf.github.io/simple-scaffold).
400
78
 
401
- export default MyComponent: React.FC = (props) => {
402
- return (
403
- <div className="myClassName">MyComponent Component</div>
404
- )
405
- }
406
- ```
79
+ - [Command Line Interface (CLI) usage](https://chenasraf.github.io/simple-scaffold/pages/cli.html)
80
+ - [Node.js usage](https://chenasraf.github.io/simple-scaffold/pages/node.html)
81
+ - [Templates](https://chenasraf.github.io/simple-scaffold/pages/templates.html)
82
+ - [Configuration Files](https://chenasraf.github.io/simple-scaffold/pages/configuration_files.html)
83
+ - [Migrating v0.x to v1.x](https://chenasraf.github.io/simple-scaffold/pages/migration.html)
407
84
 
408
85
  ## Contributing
409
86
 
@@ -0,0 +1,13 @@
1
+ /** @type {import('simple-scaffold').ScaffoldConfigFile} */
2
+ module.exports = {
3
+ default: {
4
+ templates: ["examples/test-input/Component"],
5
+ output: "examples/test-output",
6
+ data: { property: "myProp", value: "10" },
7
+ },
8
+ component: {
9
+ templates: ["examples/test-input/Component"],
10
+ output: "examples/test-output",
11
+ data: { property: "myProp", value: "10" },
12
+ },
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-scaffold",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "A simple command to generate any file structure, from single components to entire app boilerplates.",
5
5
  "homepage": "https://casraf.dev/simple-scaffold",
6
6
  "repository": "https://github.com/chenasraf/simple-scaffold.git",
@@ -44,6 +44,7 @@
44
44
  "util.promisify": "^1.1.1"
45
45
  },
46
46
  "devDependencies": {
47
+ "@knodes/typedoc-plugin-pages": "^0.23.4",
47
48
  "@semantic-release/changelog": "^6.0.3",
48
49
  "@semantic-release/git": "^10.0.1",
49
50
  "@semantic-release/release-notes-generator": "^10.0.3",
@@ -62,8 +63,5 @@
62
63
  "ts-node": "^10.9.1",
63
64
  "typedoc": "^0.24.6",
64
65
  "typescript": "^5.0.4"
65
- },
66
- "peerDependencies": {
67
- "doc-theme": "file:./doc-theme"
68
66
  }
69
67
  }
@@ -0,0 +1,7 @@
1
+ See full documentation [here](https://chenasraf.github.io/simple-scaffold).
2
+
3
+ - [Command Line Interface (CLI) usage](https://chenasraf.github.io/simple-scaffold/pages/cli.html)
4
+ - [Node.js usage](https://chenasraf.github.io/simple-scaffold/pages/node.html)
5
+ - [Templates](https://chenasraf.github.io/simple-scaffold/pages/templates.html)
6
+ - [Configuration Files](https://chenasraf.github.io/simple-scaffold/pages/configuration_files.html)
7
+ - [Migrating v0.x to v1.x](https://chenasraf.github.io/simple-scaffold/pages/migration.html)