Options
All
  • Public
  • Public/Protected
  • All
Menu

The config object for defining a scaffolding group.

see

https://github.com/chenasraf/simple-scaffold#readme

see

DefaultHelpers

see

CaseHelpers

see

DateHelpers

Hierarchy

  • ScaffoldConfig

Index

Properties

name: string

Name to be passed to the generated files. {{name}} and {{Name}} inside contents and file names will be replaced accordingly.

templates: string[]

Template files to use as input. You may provide multiple files, each of which can be a relative or absolute path, or a glob pattern for multiple file matching easily.

default

Current working directory

output: FileResponse<string>

Path to output to. If createSubFolder is true, the subfolder will be created inside this path.

May also be a FileResponseHandler which returns a new output path to override the default one.

see

FileResponse

see

FileResponseHandler

createSubFolder?: boolean

Whether to create subfolder with the input name.

When true, you may also use subFolderNameHelper to determine a pre-process helper on the directory name.

default

false

data?: Record<string, any>

Add custom data to the templates. By default, only your app name is included as {{name}} and {{Name}}.

This can be any object that will be usable by Handlebars.

overwrite?: FileResponse<boolean>

Enable to override output files, even if they already exist.

You may supply a function to this option, which can take the arguments (fullPath, baseDir, baseName) and returns a string, to return a dynamic path for each file.

May also be a FileResponseHandler which returns a boolean value per file.

see

FileResponse

see

FileResponseHandler

default

false

quiet?: boolean

Suppress output logs (Same as verbose: 0 or verbose: LogLevel.None)

see

verbose

verbose?: LogLevel

Determine amount of logs to display.

The values are: 0 (none) | 1 (debug) | 2 (info) | 3 (warn) | 4 (error). The provided level will display messages of the same level or higher.

see

LogLevel

default

2 (info)

dryRun?: boolean

Don't emit files. This is good for testing your scaffolds and making sure they don't fail, without having to write actual file contents or create directories.

default

false

helpers?: Record<string, HelperDelegate>

Additional helpers to add to the template parser. Provide an object whose keys are the name of the function to add, and the value is the helper function itself. The signature of helpers is as follows:

(text: string, ...args: any[]) => string

A full example might be:

Scaffold({
//...
helpers: {
upperKebabCase: (text) => kebabCase(text).toUpperCase()
}
})

Which will allow:

{{ upperKebabCase "my value" }}

To transform to:

MY-VALUE

See DefaultHelpers for a list of all the built-in available helpers.

Simple Scaffold uses Handlebars.js, so all the syntax from there is supported. See their docs for more information.

see

DefaultHelpers

see

CaseHelpers

see

DateHelpers

see

https://casraf.blog/simple-scaffold#helpers

see

https://casraf.blog/simple-scaffold#built-in-helpers

see

https://handlebarsjs.com/guide/#custom-helpers

subFolderNameHelper?: string

Default transformer to apply to subfolder name when using createSubFolder: true. Can be one of the default capitalization helpers, or a custom one you provide to helpers. Defaults to undefined, which means no transformation is done.

see

createSubFolder

see

CaseHelpers

see

DefaultHelpers

Methods

  • beforeWrite(content: Buffer, rawContent: Buffer, outputPath: string): undefined | string | Buffer | Promise<undefined | string | Buffer>
  • This callback runs right before content is being written to the disk. If you supply this function, you may return a string that represents the final content of your file, you may process the content as you see fit. For example, you may run formatters on a file, fix output in edge-cases not supported by helpers or data, etc.

    If the return value of this function is undefined, the original content will be used.

    Parameters

    • content: Buffer

      The original template after token replacement

    • rawContent: Buffer

      The original template before token replacement

    • outputPath: string

      The final output path of the processed file

    Returns undefined | string | Buffer | Promise<undefined | string | Buffer>

    The final output of the file contents-only, after further modifications - or undefined to use the original content (i.e. content.toString())

Generated using TypeDoc