Skip to main content
Version: Next

Functions

Data structure & behavior

  • A transformer's mode can either be display, in or out
  • The transformers entry holds the information for these three types of transformation
  • A display, in or out is an array of transformers
  • The transformers will be called sequentially as per their order in the array

Example

transformers: [
{
modes: ['in', 'display'],
id: "capitalizeFirstLetter",
},
{
modes: ['in', 'display'],
handler: ({ input }) => {
if(!input) {
return ""
}
return `{${input}}`
}
},
{
modes: ['out'],
template: `<%= destination %>/<%= protocolId %>`
}
]

Modes

In

An In transformer is applied to a value before it is presented to the inquirer.

Out

An Out transformer is applied to a value after it is presented to the inquirer and filled by the user.

Display

A Display transformer is applied to a value only for display formatting.

Create

Create a project wide transformer in the form of a _cliNext file in src/transformers/{in|out|display}.

Loading ....

Use

You can declare a transformer in three different ways

File based

Pass the id of the transformer in the corresponding section of the transformers section.

 transformers: [
{
id: 'myDisplayTransformerId',
params: {
myParam1: true
}
}
]
Parameter Type Description Default value Mandatory
idstringTransformer id
True
paramsobjectTransformer payload{}
False
modesarrayTransformers modes
True

Example

 transformers: {
display: [{
id: 'isFolderEmpty',
params: {
excludeHiddenFiles: true
}
}]
}

Inline

Parameter Type Description Default value Mandatory
idstringTransformer id
True
paramsobjectTransformer payload{}
False
Example
 transformers: {
out: ['myOutTransformerId']
}

Template

Parameter Type Description Default value Mandatory
idstringTransformer id
True
paramsobjectTransformer payload{}
False
Example
transformers: {
out: [{
template: `<%= destination %>/<%= protocolId %>`
}]
}