Options
All
  • Public
  • Public/Protected
  • All
Menu

Simple Scaffold - v1.1.2

Index

Main

  • Create a scaffold using given options.

    Create files

    To create a file structure to output, use any directory and file structure you would like. Inside folder names, file names or file contents, you may place {{ var }} where var is either name which is the scaffold name you provided or one of the keys you provided in the data option.

    The contents and names will be replaced with the transformed values so you can use your original structure as a boilerplate for other projects, components, modules, or even single files.

    The files will maintain their structure, starting from the directory containing the template (or the template itself if it is already a directory), and will output from that directory into the directory defined by config.output.

    Helpers

    Helpers are functions you can use to transform your {{ var }} contents into other values without having to pre-define the data and use a duplicated key.

    Any functions you provide in helpers option will also be available to you to make custom formatting as you see fit (for example, formatting a date)

    For available default values, see DefaultHelpers.

    see

    DefaultHelpers

    see

    CaseHelpers

    see

    DateHelpers

    Parameters

    Returns Promise<void>

Config

FileResponseHandler<T>: (fullPath: string, basedir: string, basename: string) => T

Type parameters

  • T

    The return type for the function

Type declaration

    • (fullPath: string, basedir: string, basename: string): T
    • A function that takes path information about file, and returns a value of type T

      Parameters

      • fullPath: string

        The full path of the current file

      • basedir: string

        The directory containing the current file

      • basename: string

        The name of the file

      Returns T

      A return value

FileResponse<T>: T | FileResponseHandler<T>

Represents a response for file path information. Can either be:

  1. T - static value
  2. A function with the following signature which returns T:
    (fullPath: string, basedir: string, basename: string) => T
    
see

FileResponseHandler

Type parameters

  • T

Helpers

CaseHelpers: "camelCase" | "hyphenCase" | "kebabCase" | "lowerCase" | "pascalCase" | "snakeCase" | "startCase" | "upperCase"

The names of the available helper functions that relate to text capitalization.

These are available for subfolderNameHelper.

Helper name Example code Example output
[None] {{ name }} my name
camelCase {{ camelCase name }} myName
snakeCase {{ snakeCase name }} my_name
startCase {{ startCase name }} My Name
kebabCase {{ kebabCase name }} my-name
hyphenCase {{ hyphenCase name }} my-name
pascalCase {{ pascalCase name }} MyName
upperCase {{ upperCase name }} MY NAME
lowerCase {{ lowerCase name }} my name
see

DefaultHelpers

see

DateHelpers

see

ScaffoldConfig

see

subFolderNameHelper

DateHelpers: "date" | "now"

The names of the available helper functions that relate to dates.

Helper name Description Example code Example output
now Current date with format {{ now "yyyy-MM-dd HH:mm" }} 2042-01-01 15:00
now (with offset) Current date with format, and with offset {{ now "yyyy-MM-dd HH:mm" -1 "hours" }} 2042-01-01 14:00
date Custom date with format {{ date "2042-01-01T15:00:00Z" "yyyy-MM-dd HH:mm" }} 2042-01-01 15:00
date (with offset) Custom date with format, and with offset {{ date "2042-01-01T15:00:00Z" "yyyy-MM-dd HH:mm" -1 "days" }} 2041-31-12 15:00
date (with date from --data) Custom date with format, with data from the data config option {{ date myCustomDate "yyyy-MM-dd HH:mm" }} 2042-01-01 12:00

Further details:

  • We use date-fns for parsing/manipulating the dates. If you want more information on the date tokens to use, refer to their format documentation.

  • The date helper format takes the following arguments:

    (
    date: string,
    format: string,
    offsetAmount?: number,
    offsetType?: "years" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds"
    )
  • The now helper (for current time) takes the same arguments, minus the first one (date) as it is implicitly the current date.

see

DefaultHelpers

see

CaseHelpers

see

ScaffoldConfig

DefaultHelpers: CaseHelpers | DateHelpers

The names of all the available helper functions in templates. Simple-Scaffold provides some built-in text transformation filters usable by Handlebars.js.

For example, you may use {{ snakeCase name }} inside a template file or filename, and it will replace My Name with my_name when producing the final value.

see

CaseHelpers

see

DateHelpers

see

ScaffoldConfig

Helper: HelperDelegate

Other

Renames and re-exports Scaffold

Generated using TypeDoc