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

target_operations

Marcel Kloubert edited this page Dec 22, 2017 · 38 revisions

Home >> Targets >> Operations

Operations

This page describes the supported operation types, which can be defined with beforeDeploy and deployed properties inside a target.

Table of contents

command []

Executes a Visual Studio Code command.

{
    "deploy.reloaded": {
        "targets": [
            {
                "type": "test",
                "name": "This is a test",

                "beforeDeploy": [
                    {
                        "type": "command",
                        "command": "workbench.action.tasks.build"
                    }
                ]
            }
        ]
    }
}
Name Description
arguments One or more optional argument for the execution.
command* The ID of the command to execute.

* supports placeholders

http []

Does a HTTP request.

{
    "deploy.reloaded": {
        "targets": [
            {
                "type": "sftp",
                "name": "My site",

                "host": "mysite.example.com",
                "user": "mkloubert", "password": "P@assword123!",

                "deployed": [
                    {
                        "type": "http",
                        
                        "url": "https://mysite.example.com/flush_cache.php",
                        "headers": {
                            "Authorization": "Basic bWtsb3ViZXJ0OlBhdWxpbmFaU3V4"
                        }
                    }
                ]
            }
        ]
    }
}
Name Description
body* The body or the path to a script that returns the body to send.
headers** The object that contains the request headers and their values by properties.
isBodyBase64 Is value in body property Base64 encoded or not. Default: (false)
isBodyScript Is value in body property the path to a script that returns the body to send or not. Default: (false)
method The HTTP request method. Default: GET
noPlaceholdersForTheseHeaders A list of one or more header names, where placeholders should not be applied to. This can also be a boolean value that indicates if the feature should be enabled for all headers or not. Default: (true)
options The value or object for the body script.
password The password for basic authentication.
url The URL to call.
username The username for basic authentication.

* supports placeholders, but only if script (isBodyScript = (true))
** supports placeholders

Body scripts []

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

exports.getBody = function(args) {
    // return a string or Buffer
    // directly or as Promise (if async)
}

The args parameter uses the HttpBodyModuleExecutionArguments interface.

open []

Opens a target, like an executable or a website.

{
    "deploy.reloaded": {
        "targets": [
            {
                "type": "test",
                "name": "This is a test",

                "deployed": [
                    {
                        "type": "open",
                        "target": "https://github.com/mkloubert"
                    }
                ]
            }
        ]
    }
}
Name Description
target* The thing that should be opened. Can be a URL, file or executable.
wait Wait until execution has been finished or not. Default: (true)

* supports placeholders

Or shorter:

{
    "deploy.reloaded": {
        "targets": [
            {
                // ...

                "deployed": [
                    "https://github.com/mkloubert"
                ]
            }
        ]
    }
}

script []

Runs a script from a file.

{
    "deploy.reloaded": {
        "targets": [
            {
                "type": "test",
                "name": "This is a test",

                "beforeDeploy": [
                    {
                        "type": "script",
                        
                        "script": "./my_beforeDeploy_script.js",
                        "options": 5979 
                    }
                ]
            }
        ]
    }
}
Name Description
options Additional options for the script execution.
script The path to the script file.

A script looks like that:

exports.execute = function(args) {
    // do the MAGIC here

    // from the configuration example
    // above 'args.options' would contain
    // 5979 as value

    // return NOTHING or a Promise
    // to indicate an ASYNC execution
}

args

s. ScriptTargetOperationExecutionArguments

sql []

Executes SQL scripts.

{
    "deploy": {
        "targets": [
            {
                "type": "test",
                "name": "This is a test",

                "beforeDeploy": [
                    {
                        "type": "sql",
                        
                        "engine": "mysql",
                        "options": {
                            "host": "mysql.example.com",
                            "user": "dbUser",
                            "password": "P@assword123!", 
                            "database": "myDatabase"
                        },

                        "queries": [
                            "TRUNCATE TABLE `logs`"
                        ]
                    }
                ]
            }
        ]
    }
}
Name Description
engine The engine to use. Default: mysql
options The options for the connection.
queries One or more query to invoke.

engine []

Name Description
mysql MySQL
sql Microsoft SQL

options []

MySQL []

Name Description
database The database to connect to.
host The host. Default: 127.0.0.1
port The TCP port. Default: 3306
password The password.
rejectUnauthorized Reject untrusted SSL connections or not.
user The username. Default: root

SQL (Microsoft SQL) []

Name Description
database The database to connect to.
driver The driver to use (for more information s. mssql). Default: tedious
encrypt Encrypt the connection or not. Default: (false)
host The host. Default: 127.0.0.1
port The TCP port. Default: 1433
password The password.
user The username. Default: sa

wait []

Waits a number of milliseconds, before the next operation is executed.

{
    "deploy.reloaded": {
        "targets": [
            {
                "type": "test",
                "name": "This is a test",

                "beforeDeploy": [
                    {
                        "type": "wait",
                        "time": 1000
                    }
                ]
            }
        ]
    }
}
Name Description
time The number of milliseconds to wait before next operation is invoked.
Clone this wiki locally