Skip to main content

create-pantheon-decoupled-kit

Interfaces

Type Aliases

Action

Ƭ Action: (config: ActionConfig) => Promise<string> | string

Type declaration

▸ (config): Promise<string> | string

An action that takes in the data, templates, and an instance of handlebars and does an action, like installing dependencies or formatting generated code

Parameters
NameType
configActionConfig
Returns

Promise<string> | string

Defined in

src/types.ts:111


ActionRunner

Ƭ ActionRunner: (config: ActionRunnerConfig) => Promise<string>

Type declaration

▸ (config): Promise<string>

Parameters
NameType
configActionRunnerConfig
Returns

Promise<string>

Defined in

src/types.ts:113


BaseGeneratorData

Ƭ BaseGeneratorData: Partial<PackageVersionData> & DrupalOrWP

Base data that is passed to all generators

Example

{
drupalKitVersion: versions['drupal-kit'],
drupal: true
}

Defined in

src/types.ts:38


Input

Ƭ Input: { [Property in keyof InputIndex]: InputIndex[Property] }

Input from command line arguments, prompts, and generator data

Defined in

src/types.ts:142


TemplateFn

Ƭ TemplateFn: <Data>({ data, utils, }: TemplateFnArgs<Data>) => string

Type declaration

▸ <Data>({ data, utils, }): string

A tagged template literal function with data and utils context

Type parameters
NameType
Dataextends Input
Parameters
NameType

| { data, utils, } | TemplateFnArgs<Data> |

Returns

string

Defined in

src/types.ts:185

Variables

TAGGED_TEMPLATE_REGEX

Const TAGGED_TEMPLATE_REGEX: RegExp

Remarks

env\.[a-z.]* - matches .env.*.ts such as .env.development.local.ts

Defined in

src/utils/constants.ts:5


hbsHelpers

Const hbsHelpers: Object

Handlebars HelperDelegate

Index signature

[key: string]: HelperDelegate

Defined in

src/utils/handlebars.ts:10


rootDir

Const rootDir: string

Defined in

src/index.ts:15


taggedTemplateHelpers

Const taggedTemplateHelpers: Object

Type declaration

NameType
backticks(value: string | TemplateStringsArray) => string
if(condition: unknown, value: string) => string
md{ codeFence: (__namedParameters: { lang: Lang ; value: string }) => string }
md.codeFence(__namedParameters: { lang: Lang ; value: string }) => string
pkgName(value: unknown) => string
wpGraphql(value: string) => string

Defined in

src/utils/taggedTemplateHelpers.ts:8

Functions

actionRunner

actionRunner(config): Promise<string>

Parameters

NameType
configActionRunnerConfig

Returns

Promise<string>

Defined in

src/types.ts:113


addDependencies

addDependencies(config): string | Promise<string>

Adds any dependencies and/or devDependencies from the data field

Parameters

NameType
configActionConfig

Returns

string | Promise<string>

Defined in

src/types.ts:111


addWithDiff

addWithDiff(config): string | Promise<string>

  1. dedupe the templates, favoring addons in case 2 paths collide
  2. check if the destination path exists or create it. (path to destination + template name minus .hbs) example: ./test/myTest.js
  3. check the diff against the new file and the rendered template or file to copy if source is not a handlebars template
  4. if the --force option is not defined, ask the user if we should overwrite this file (yes to all, yes, skip, abort) if force is true we write everything.
  5. skip or write the file based on input. If yes to all, set force to true.

Parameters

NameType
configActionConfig

Returns

string | Promise<string>

Defined in

src/types.ts:111


convertCSSModules

convertCSSModules(config): string | Promise<string>

An action that takes in the data, templates, and an instance of handlebars and does an action, like installing dependencies or formatting generated code

Parameters

NameType
configActionConfig

Returns

string | Promise<string>

Defined in

src/types.ts:111


dedupeTemplates

dedupeTemplates(templateData): Promise<MergedPaths>

In case there is a template path that exists in two or more generators, we want to favor the addon. This way, we avoid writing to a file multiple times

Parameters

NameTypeDescription
templateDataTemplateData[]An array of Templates

Returns

Promise<MergedPaths>

MergedPaths

See

Defined in

src/utils/dedupeTemplates.ts:70


getHandlebarsInstance

getHandlebarsInstance(rootDir): Promise<typeof Handlebars>

Parameters

NameTypeDescription
rootDirstringdir to look for the partials dir from

Returns

Promise<typeof Handlebars>

an instance of handlebars our with helpers and partials registered

Example

resolves to {rootDir}/templates/partials

Defined in

src/utils/handlebars.ts:119


helpMenu

helpMenu(generators): string

Parameters

NameType
generatorsDecoupledKitGenerator<DefaultAnswers, unknown>[]

Returns

string

Defined in

src/utils/helpMenu.ts:3


isDrupalCms

isDrupalCms(value): value is "drupal" | "d9" | "d10"

Parameters

NameTypeDescription
valuestringa string

Returns

value is "drupal" | "d9" | "d10"

true if the variable matches a Drupal alias in CMSType['Drupal'], false otherwise

Defined in

src/types.ts:206


isString

isString(arg): arg is string

Parameters

NameTypeDescription
argunknowna variable

Returns

arg is string

true if the variable is a string, false otherwise

Defined in

src/types.ts:198


isWpCms

isWpCms(value): value is "wp" | "wordpress"

Parameters

NameTypeDescription
valuestringa string

Returns

value is "wp" | "wordpress"

true if the variable matches a WordPress alias in CMSType['WordPress'], false otherwise

Defined in

src/types.ts:214


main

main(args, DecoupledKitGenerators): Promise<void>

Initializes the CLI prompts based on parsed arguments

Parameters

NameTypeDescription
argsParsedArgsParsedArgs
DecoupledKitGeneratorsDecoupledKitGenerator<DefaultAnswers, unknown>[]An array of decoupledKitGenerators.

Returns

Promise<void>

Runs the actions for the generators given as positional params or if none are found, prompts user to select valid generator from list of DecoupledKitGenerators

See

decoupledKitGenerators.

Remarks

positional args are assumed to be generator names. Multiple generators can be queued up this way. Any number of prompts may be skipped by passing in the prompt name via flag.

Defined in

src/index.ts:51


parseArgs

parseArgs(cliArgs?): ParsedArgs

Parses CLI arguments using minimist

Parameters

NameTypeDescription
cliArgsstring[]an array of strings.

Returns

ParsedArgs

See

https://www.npmjs.com/package/minimist#var-argv--parseargsargs-opts

Default Value

process.argv.slice(2)

Defined in

src/index.ts:23


runInstall

runInstall(config): string | Promise<string>

An action that takes in the data, templates, and an instance of handlebars and does an action, like installing dependencies or formatting generated code

Parameters

NameType
configActionConfig

Returns

string | Promise<string>

Defined in

src/types.ts:111


runLint

runLint(config): string | Promise<string>

An action that takes in the data, templates, and an instance of handlebars and does an action, like installing dependencies or formatting generated code

Parameters

NameType
configActionConfig

Returns

string | Promise<string>

Defined in

src/types.ts:111