Skip to content

Commit 943aad1

Browse files
committed
docs: update docs
1 parent 9fb4762 commit 943aad1

3 files changed

Lines changed: 54 additions & 8 deletions

File tree

README.md

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ To generate the template output, run:
5959

6060
```shell
6161
# generate single component
62-
npx simple-scaffold@latest \
62+
$ npx simple-scaffold@latest \
6363
-t templates/component -o src/components PageWrapper
6464
```
6565

@@ -76,27 +76,73 @@ export default PageWrapper: React.FC = (props) => {
7676
}
7777
```
7878

79-
### Remote Templates
79+
### Configuration Files
80+
81+
You can also use a config file to more easily maintain all your scaffold definitions.
82+
83+
`scaffold.config.js`
84+
85+
```js
86+
module.exports = {
87+
// use "default" to avoid needing to specify key
88+
// in this case the key is "component"
89+
component: {
90+
templates: ["templates/component"],
91+
output: "src/components",
92+
data: {
93+
// ...
94+
},
95+
},
96+
}
97+
```
98+
99+
Then call your scaffold like this:
100+
101+
```shell
102+
$ npx simple-scaffold@latest -c scaffold.config.js PageWrapper
103+
```
104+
105+
This will allow you to avoid needing to remember which configs are needed or to store them in a
106+
1-liner in `packqge.json` which can get pretty long and messy, which is harder to maintain.
107+
108+
Also, this allows you to define more complex scaffolds with logic without having to use the Node.js
109+
API directly. (Of course you always have the option to still do so if you wish)
110+
111+
See more at the [CLI documentation](https://chenasraf.github.io/simple-scaffold/pages/cli.html) and
112+
[Configuration Files](https://chenasraf.github.io/simple-scaffold/pages/configuration_files.html).
113+
114+
### Remote Configurations
80115

81116
Another quick way to start is to re-use someone else's (or your own) work using a template
82117
repository.
83118

119+
A remote config can be loaded in one of these ways:
120+
121+
- If it's on GitHub, you can use `-gh user/repository_name`
122+
- If it's on another git server (such as GitLab), you can use
123+
`-c https://example.com/user/repository_name.git`
124+
125+
Configurations can hold multiple scaffold groups. Each group can be accessed using its key by
126+
supplying the `--key` or `-k` argument, or by appending a hash and then the key name, like so:
127+
`-gh user/repository_name#key_name` - this also works for the `-c` flag.
128+
84129
Here is an example for loading the example component templates in this very repository:
85130

86131
```shell
87-
npx simple-scaffold@latest \
88-
-gh chenasraf/simple-scaffold#examples/test-input/scaffold.config.js:component \
132+
$ npx simple-scaffold@latest \
133+
-gh chenasraf/simple-scaffold#scaffold.config.js:component \
89134
PageWrapper
90135

91136
# equivalent to:
92-
npx simple-scaffold@latest \
93-
-c https://github.com/chenasraf/simple-scaffold.git#examples/test-input/scaffold.config.js:component \
137+
$ npx simple-scaffold@latest \
138+
-c https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js:component \
94139
PageWrapper
95140
```
96141

97142
When template name (`:component`) is omitted, `default` is used.
98143

99-
See more at the [CLI documentation](https://chenasraf.github.io/simple-scaffold/pages/cli.html)
144+
See more at the [CLI documentation](https://chenasraf.github.io/simple-scaffold/pages/cli.html) and
145+
[Configuration Files](https://chenasraf.github.io/simple-scaffold/pages/configuration_files.html).
100146

101147
## Documentation
102148

src/scaffold.ts

100755100644
File mode changed.

src/types.ts

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export interface ScaffoldConfig {
5757
* Enable to override output files, even if they already exist.
5858
*
5959
* You may supply a function to this option, which can take the arguments `(fullPath, baseDir, baseName)` and returns
60-
* a string, to return a dynamic path for each file.
60+
* a boolean for each file.
6161
*
6262
* May also be a {@link FileResponseHandler} which returns a boolean value per file.
6363
*

0 commit comments

Comments
 (0)