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 30, 2017 · 38 revisions

Home >> Targets >> Operations

Operations

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

Table of contents

All operation types support the following settings:

Name Description
if (JavaScript) Code, which checks if operation should be executed or not.
ignoreIfFail Continue if execution fails or not. Default: (false)
name The custom (display) name.
type The type. Default: open

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

exec []

Executes a shell command inside the workspace.

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

                "beforeDeploy": [
                    {
                        "type": "exec",
                        "target": "npm install"
                    }
                ]
            }
        ]
    }
}
Name Description
command* The (shell) command to execute.
cwd* The custom working directory for the execution. Relative paths will be mapped to the root directory of the underlying workspace.
noPlaceHolders Do not use placeholders in command property. Default: (false)

* 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.

Relative paths will be mapped to your home directory (.vscode-deploy-reloaded sub folder) or the .vscode folder.

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. Relative paths will be mapped to your home directory (.vscode-deploy-reloaded sub folder) or the .vscode folder.

* supports placeholders

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.reloaded": {
        "targets": [
            {
                "type": "test",
                "name": "This is a test",

                "deployed": [
                    {
                        "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.
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