docs: update docs

This commit is contained in:
2024-01-21 23:17:12 +02:00
committed by Chen Asraf
parent c04d1cc42a
commit 3b60f1816d
5 changed files with 44 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
import * as React from "react"
import * as css from "./{{Name}}.css"
import * as css from "./{{pascalCae name}}.css"
class {{Name}} extends React.Component<any> {
class {{pascalCae name}} extends React.Component<any> {
private {{ property }}
constructor(props: any) {
@@ -10,8 +10,8 @@ class {{Name}} extends React.Component<any> {
}
public render() {
return <div className={ css.{{Name}} } />
return <div className={ css.{{pascalCae name}} } />
}
}
export default {{Name}}
export default {pascalCae nName}}

View File

@@ -4,4 +4,4 @@ See full documentation [here](https://chenasraf.github.io/simple-scaffold).
- [Node.js usage](https://chenasraf.github.io/simple-scaffold/pages/node.html)
- [Templates](https://chenasraf.github.io/simple-scaffold/pages/templates.html)
- [Configuration Files](https://chenasraf.github.io/simple-scaffold/pages/configuration_files.html)
- [Migrating v0.x to v1.x](https://chenasraf.github.io/simple-scaffold/pages/migration.html)
- [Migrating between major versions](https://chenasraf.github.io/simple-scaffold/pages/migration.html)

View File

@@ -77,20 +77,20 @@ module.exports = (config) => {
## Using a config file
Once your config is created, you can use it by providing the file name to the `--config` (or `-c`
for brevity), optionally followed by a colon, then your scaffold config name.
for brevity), optionally alongside `--key` or `-k`, denoting the key to use as the config object, as
you define in your config:
```shell
simple-scaffold -c <file>[:<template_key>]
simple-scaffold -c <file> -k <template_key>
```
For example:
```shell
simple-scaffold -c scaffold.json:component MyComponentName
simple-scaffold -c scaffold.json -k component MyComponentName
```
If you don't want to supply a template/config name (e.g. `component`), you can omit the colon and
the name, and it will use the configuration named `default`:
If you don't want to supply a template/config name (e.g. `component`), `default` will be used:
```js
/** @type {import('simple-scaffold').ScaffoldConfigFile} */
@@ -108,6 +108,19 @@ And then:
simple-scaffold -c scaffold.json MyComponentName
```
Any importable file is supported, depending on your build process.
Common files include:
- `*.json`
- `*.js`
- `*.mjs`
- `*.cjs`
Note that you might need to find the correct extension of `.js`, `.cjs` or `.mjs` depending on your
build process and your package type (for example, packages with `"type": "module"` in their
`package.json` might be required to use `.mjs`.
## Remote Templates
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
The syntax is as follows:
```shell
simple-scaffold -c <git_url>[#<git_file>][:<template_key>]
simple-scaffold -c <git_url>[#<git_file>] [-k <template_key>]
```
For example, to use this repository's example as base:
```shell
simple-scaffold -c https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js:component
simple-scaffold -c https://github.com/chenasraf/simple-scaffold.git#scaffold.config.js -k component
```
When the `filename` is omitted, `/scaffold.config.js` will be used as default.
@@ -141,13 +154,13 @@ URL without specifying the whole path.
The syntax is as follows:
```shell
simple-scaffold -gh <username>/<project_name>[#<git_file>][:<template_key>]
simple-scaffold -gh <username>/<project_name>[#<git_file>] [-k <template_key>]
```
This example is equivalent to the above, just shorter to write:
```shell
simple-scaffold -c chenasraf/simple-scaffold#scaffold.config.js:component
simple-scaffold -c chenasraf/simple-scaffold#scaffold.config.js -k component
```
## Use In Node.js

View File

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

View File

@@ -124,7 +124,3 @@ export async function getConfig(config: ConfigLoadConfig): Promise<ScaffoldConfi
return wrapNoopResolver(import(path.resolve(process.cwd(), configFile)))
}
function count(string: string, substring: string): number {
return string.split(substring).length - 1
}