Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

target_prompt

Marcel Kloubert edited this page Jun 10, 2017 · 21 revisions

Home >> Targets >> prompt

Prompt

Asks the user for a list of settings that will be applied to one or more other targets.

The following example lets the user input an username and password and writes these values to user and password settings of FTP server template.

{
    "deploy": {
        "targets": [
            {
                "type": "prompt",
                "name": "FTP server",

                "prompts": [
                    {
                        "text": "Please enter your username",

                        "properties": [ "user" ],
                        "defaultValue": "/my_package_files",

                        "cache": true,
                        "showAlways": true
                    },
                    
                    {
                        "valuePlaceHolder": "Please enter the password for '${user}'",
                        
                        "isPassword": true,
                        "properties": [ "password" ],
                        
                        "cache": true
                    }
                ],
                
                "targets": [ "FTP server template" ]
            },
            
            {
                "name": "FTP server template",
                "type": "ftp",
                
                "isHidden": true,

                "user": "<NO NEED TO SET: This is done by 1st prompt of 'FTP server' target>",
                "password": "<NO NEED TO SET: This is done by 2nd prompt of 'FTP server' target>"
            }
        ]
    }
}
Name Description
prompts One or more prompt entry.
targets One or more target name to deploy to.

Prompts

Name Description
cache Save value in cache or not. Default: (false)
converter The path to a script that converts an user input.
converterOptions The options for the converter script.
defaultValue The initial value.
description A description for the entry.
ignoreFocusOut Set to (true) to keep the input box open when focus moves to another part of the editor or to another window. Default: (true)
isPassword Input value is secret / a password. Default: (false)
properties A list of one or more property names inside the target where to write the value to.
showAlways Always show input box even if cached. Default: (false)
text* The text for the input box.
type The value type. Default: string
validator The path to a script that validates an user input.
validatorOptions The options for the validator script.
valuePlaceHolder* The placeholder for the input box.

* supports placeholders

Types

Name Description
bool, boolean Convert to a boolean value. Possible value for (true) are: 1, true, yes or y. All other values, expect of an empty string, will be handled as (false).
file Loads data from a file and parses it as JSON string.
float, number Convert to a number / float value.
int, integer Convert to an integer value.
json, object, obj Parses a value as JSON string.
string Does no conversion.

Converter script

A script must have a public / exported convert() function:

exports.convert = function(args) {
    // convert value in
    // args.value
    // and
    // return the converted value
    // as Promise
    // or directly
};

The args parameter uses the ValueConverterModuleExecutorArguments interface.

Validator script

A script must have a public / exported validate() function:

exports.validate = function(args) {
    // s. https://mkloubert.github.io/vs-deploy/modules/_helpers_.html
    var helpers = args.require('./helpers');

    if (helpers.isEmptyString(args.value)) {
        args.message = 'Value cannot be empty!';
        return false;
    }

    // (true) is the default value
};

The args parameter uses the ValueValidatorModuleExecutorArguments interface.

Clone this wiki locally