From 3b60f1816d85c1e40f8837edbc9b358e01dee3ab Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Sun, 21 Jan 2024 23:17:12 +0200 Subject: [PATCH] docs: update docs --- .../Component/{{pascalCase name}}.tsx | 8 ++--- pages/README.md | 2 +- pages/configuration_files.md | 31 +++++++++++++------ pages/migration.md | 17 ++++++++++ src/config.ts | 4 --- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/examples/test-input/Component/{{pascalCase name}}.tsx b/examples/test-input/Component/{{pascalCase name}}.tsx index e45f681..61a5b7c 100644 --- a/examples/test-input/Component/{{pascalCase name}}.tsx +++ b/examples/test-input/Component/{{pascalCase name}}.tsx @@ -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 { +class {{pascalCae name}} extends React.Component { private {{ property }} constructor(props: any) { @@ -10,8 +10,8 @@ class {{Name}} extends React.Component { } public render() { - return
+ return
} } -export default {{Name}} +export default {pascalCae nName}} diff --git a/pages/README.md b/pages/README.md index 60227a5..5df748b 100644 --- a/pages/README.md +++ b/pages/README.md @@ -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) diff --git a/pages/configuration_files.md b/pages/configuration_files.md index 92e4e78..fecffc9 100644 --- a/pages/configuration_files.md +++ b/pages/configuration_files.md @@ -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 [:] +simple-scaffold -c -k ``` 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 [#][:] +simple-scaffold -c [#] [-k ] ``` 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 /[#][:] +simple-scaffold -gh /[#] [-k ] ``` 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 diff --git a/pages/migration.md b/pages/migration.md index 93be89b..cf97ea8 100644 --- a/pages/migration.md +++ b/pages/migration.md @@ -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: diff --git a/src/config.ts b/src/config.ts index 2005e50..c1af977 100644 --- a/src/config.ts +++ b/src/config.ts @@ -124,7 +124,3 @@ export async function getConfig(config: ConfigLoadConfig): Promise