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
Name | Type |
---|---|
config | ActionConfig |
Returns
Promise
<string
> | string
Defined in
ActionRunner
Ƭ ActionRunner: (config
: ActionRunnerConfig
) => Promise
<string
>
Type declaration
▸ (config
): Promise
<string
>
Parameters
Name | Type |
---|---|
config | ActionRunnerConfig |
Returns
Promise
<string
>
Defined in
BaseGeneratorData
Ƭ BaseGeneratorData: Partial
<PackageVersionData
> & DrupalOrWP
Base data that is passed to all generators
Example
{
drupalKitVersion: versions['drupal-kit'],
drupal: true
}
Defined in
Input
Ƭ Input: { [Property in keyof InputIndex]: InputIndex[Property] }
Input from command line arguments, prompts, and generator data
Defined in
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
Name | Type |
---|---|
Data | extends Input |
Parameters
Name | Type |
---|
| { data, utils, }
| TemplateFnArgs
<Data
> |
Returns
string
Defined in
Variables
TAGGED_TEMPLATE_REGEX
• Const
TAGGED_TEMPLATE_REGEX: RegExp
Remarks
env\.[a-z.]*
- matches .env.*.ts
such as .env.development.local.ts
Defined in
hbsHelpers
• Const
hbsHelpers: Object
Handlebars HelperDelegate
Index signature
▪ [key: string
]: HelperDelegate
Defined in
rootDir
• Const
rootDir: string
Defined in
taggedTemplateHelpers
• Const
taggedTemplateHelpers: Object
Type declaration
Name | Type |
---|---|
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
Name | Type |
---|---|
config | ActionRunnerConfig |
Returns
Promise
<string
>
Defined in
addDependencies
▸ addDependencies(config
): string
| Promise
<string
>
Adds any dependencies and/or devDependencies from the data field
Parameters
Name | Type |
---|---|
config | ActionConfig |
Returns
string
| Promise
<string
>
Defined in
addWithDiff
▸ addWithDiff(config
): string
| Promise
<string
>
- dedupe the templates, favoring addons in case 2 paths collide
- check if the destination path exists or create it. (path to destination + template name minus .hbs) example: ./test/myTest.js
- check the diff against the new file and the rendered template or file to copy if source is not a handlebars template
- 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.
- skip or write the file based on input. If yes to all, set force to true.
Parameters
Name | Type |
---|---|
config | ActionConfig |
Returns
string
| Promise
<string
>
Defined in
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
Name | Type |
---|---|
config | ActionConfig |
Returns
string
| Promise
<string
>
Defined in
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
Name | Type | Description |
---|---|---|
templateData | TemplateData [] | An array of Templates |
Returns
Promise
<MergedPaths
>
MergedPaths
See
- Template
- MergedPaths
Defined in
src/utils/dedupeTemplates.ts:70
getHandlebarsInstance
▸ getHandlebarsInstance(rootDir
): Promise
<typeof Handlebars
>
Parameters
Name | Type | Description |
---|---|---|
rootDir | string | dir 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
helpMenu
▸ helpMenu(generators
): string
Parameters
Name | Type |
---|---|
generators | DecoupledKitGenerator <DefaultAnswers , unknown >[] |
Returns
string
Defined in
isDrupalCms
▸ isDrupalCms(value
): value is "drupal" | "d9" | "d10"
Parameters
Name | Type | Description |
---|---|---|
value | string | a string |
Returns
value is "drupal" | "d9" | "d10"
true if the variable matches a Drupal alias in CMSType['Drupal'], false otherwise
Defined in
isString
▸ isString(arg
): arg is string
Parameters
Name | Type | Description |
---|---|---|
arg | unknown | a variable |
Returns
arg is string
true if the variable is a string, false otherwise
Defined in
isWpCms
▸ isWpCms(value
): value is "wp" | "wordpress"
Parameters
Name | Type | Description |
---|---|---|
value | string | a string |
Returns
value is "wp" | "wordpress"
true if the variable matches a WordPress alias in CMSType['WordPress'], false otherwise
Defined in
main
▸ main(args
, DecoupledKitGenerators
): Promise
<void
>
Initializes the CLI prompts based on parsed arguments
Parameters
Name | Type | Description |
---|---|---|
args | ParsedArgs | ParsedArgs |
DecoupledKitGenerators | DecoupledKitGenerator <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
parseArgs
▸ parseArgs(cliArgs?
): ParsedArgs
Parses CLI arguments using minimist
Parameters
Name | Type | Description |
---|---|---|
cliArgs | string [] | 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
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
Name | Type |
---|---|
config | ActionConfig |
Returns
string
| Promise
<string
>
Defined in
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
Name | Type |
---|---|
config | ActionConfig |
Returns
string
| Promise
<string
>