Skip to content

Commit 3b0fc7a

Browse files
committed
docs: update docs
1 parent 0bb282c commit 3b0fc7a

5 files changed

Lines changed: 44 additions & 18 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react"
2-
import * as css from "./{{Name}}.css"
2+
import * as css from "./{{pascalCae name}}.css"
33

4-
class {{Name}} extends React.Component<any> {
4+
class {{pascalCae name}} extends React.Component<any> {
55
private {{ property }}
66

77
constructor(props: any) {
@@ -10,8 +10,8 @@ class {{Name}} extends React.Component<any> {
1010
}
1111

1212
public render() {
13-
return <div className={ css.{{Name}} } />
13+
return <div className={ css.{{pascalCae name}} } />
1414
}
1515
}
1616

17-
export default {{Name}}
17+
export default {pascalCae nName}}

pages/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ See full documentation [here](https://chenasraf.github.io/simple-scaffold).
44
- [Node.js usage](https://chenasraf.github.io/simple-scaffold/pages/node.html)
55
- [Templates](https://chenasraf.github.io/simple-scaffold/pages/templates.html)
66
- [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)
7+
- [Migrating between major versions](https://chenasraf.github.io/simple-scaffold/pages/migration.html)

pages/configuration_files.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,20 @@ module.exports = (config) => {
7777
## Using a config file
7878

7979
Once your config is created, you can use it by providing the file name to the `--config` (or `-c`
80-
for brevity), optionally followed by a colon, then your scaffold config name.
80+
for brevity), optionally alongside `--key` or `-k`, denoting the key to use as the config object, as
81+
you define in your config:
8182

8283
```shell
83-
simple-scaffold -c <file>[:<template_key>]
84+
simple-scaffold -c <file> -k <template_key>
8485
```
8586

8687
For example:
8788

8889
```shell
89-
simple-scaffold -c scaffold.json:component MyComponentName
90+
simple-scaffold -c scaffold.json -k component MyComponentName
9091
```
9192

92-
If you don't want to supply a template/config name (e.g. `component`), you can omit the colon and
93-
the name, and it will use the configuration named `default`:
93+
If you don't want to supply a template/config name (e.g. `component`), `default` will be used:
9494

9595
```js
9696
/** @type {import('simple-scaffold').ScaffoldConfigFile} */
@@ -108,6 +108,19 @@ And then:
108108
simple-scaffold -c scaffold.json MyComponentName
109109
```
110110

111+
Any importable file is supported, depending on your build process.
112+
113+
Common files include:
114+
115+
- `*.json`
116+
- `*.js`
117+
- `*.mjs`
118+
- `*.cjs`
119+
120+
Note that you might need to find the correct extension of `.js`, `.cjs` or `.mjs` depending on your
121+
build process and your package type (for example, packages with `"type": "module"` in their
122+
`package.json` might be required to use `.mjs`.
123+
111124
## Remote Templates
112125

113126
You can load template groups remotely, similar to how you would pass a config normally.
@@ -120,13 +133,13 @@ When passing a git URL to `--config`, you will clone that repo and use the files
120133
The syntax is as follows:
121134

122135
```shell
123-
simple-scaffold -c <git_url>[#<git_file>][:<template_key>]
136+
simple-scaffold -c <git_url>[#<git_file>] [-k <template_key>]
124137
```
125138
126139
For example, to use this repository's example as base:
127140
128141
```shell
129-
simple-scaffold -c https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js:component
142+
simple-scaffold -c https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js -k component
130143
```
131144
132145
When the `filename` is omitted, `/scaffold.config.js` will be used as default.
@@ -141,13 +154,13 @@ URL without specifying the whole path.
141154
The syntax is as follows:
142155
143156
```shell
144-
simple-scaffold -gh <username>/<project_name>[#<git_file>][:<template_key>]
157+
simple-scaffold -gh <username>/<project_name>[#<git_file>] [-k <template_key>]
145158
```
146159
147160
This example is equivalent to the above, just shorter to write:
148161
149162
```shell
150-
simple-scaffold -c chenasraf/simple-scaffold#scaffold.config.js:component
163+
simple-scaffold -c chenasraf/simple-scaffold#scaffold.config.js -k component
151164
```
152165
153166
## Use In Node.js

pages/migration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# v1.x to v2.x
2+
3+
- The `:template_key` syntax has been removed. You can still use `-k template_key` to achieve the
4+
same result.
5+
- Data is no longer auto-populated with `Name` (PascalCase) by default. You can just use the helper
6+
in your templates contents and file names, simply use `{{ pascalCase name }}` instead of
7+
`{{ Name }}`. `Name` was arbitrary and it is confusing (is it `Title Case`? `PascalCase`? only
8+
reading the docs can tell). Alternatively, you can inject the transformed name into your `data`
9+
manually using a scaffold config file, by using the Node API or by appending the data to the CLI
10+
invocation.
11+
- `verbose` can now take the names `debug`, `info`, `warn`, `error` or `none` (case insensitive) or
12+
as usual by using the numbering from before.
13+
- All boolean flags no longer take a value. `-q` instead of `-q 1` or `-q true`, `-s` instead of
14+
`-s 1`, `-w` instead of `-w 1`, etc.
15+
16+
# v0.x to v1.x
17+
118
In Simple Scaffold v1.0, the entire codebase was overhauled, yet usage remains mostly the same
219
between versions. With these notable exceptions:
320

src/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,3 @@ export async function getConfig(config: ConfigLoadConfig): Promise<ScaffoldConfi
124124

125125
return wrapNoopResolver(import(path.resolve(process.cwd(), configFile)))
126126
}
127-
128-
function count(string: string, substring: string): number {
129-
return string.split(substring).length - 1
130-
}

0 commit comments

Comments
 (0)