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

targetoperations

Marcel Kloubert edited this page Nov 1, 2017 · 87 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

compile []

Compiles files.

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

                "beforeDeploy": [
                    {
                        "type": "compile",
                        
                        "compiler": "less",
                        "options": {
                            "files": [ "/styles/**/*.less" ]
                        }
                    }
                ]
            }
        ]
    }
}
Name Description
compiler The compiler to use.
options Options for the compiler.
useFilesOfDeployment Use files that will be deployed / have been deployed as source or not. Default: (false)

compiler []

Name Description
coffeescript CoffeeScript
htmlminifier html-minifier
less LESS
pug Pug
script Script based compiler.
typescript TypeScript
uglifyjs UglifyJS

options []

Name Description
exclude A list of files to exclude (s. node-glob).
files A list of files to compile (s. node-glob).
CoffeeScript []
Name Description
extension The custom file extension for the output files to use. Default: js
files Default: /**/*.coffee
sourceMap Generate source map files or not. Default: (false)
html-minifier []
Name Description
files Default: /**/*.html

For more options visit Options Quick Reference.

LESS []
Name Description
compress Compress files or not. Default: (false)
extension The custom file extension for the output files to use. Default: css
files Default: /**/*.less
paths Search paths for @import directives.
Pug []
Name Description
compileDebug When (false) no debug instrumentation is compiled. Default: (false)
extension The custom file extension for the output files to use. Default: html
files Default: /**/*.pug
pretty Add pretty-indentation whitespace to output. Default: (false)
Script []
Name Description
data Additional data for the compilation.
script The path to the script to execute. Default: ./compile.js

Example of a compiler script:

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

    // if errors where occurred, fill
    // the args.result.errors array with the
    // error data

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

The args parameter uses the ScriptCompilerArguments interface.

TypeScript []
Name Description
files Default: /**/*.ts

There also a lot of more options. Read Using the Compiler API to get more information.

UglifyJS []
Name Description
deleteSources Delete source files or not. Default: (false)
extension Custom extension for the output files. Default: min.js
files Default: /**/*.js

There also a lot of more options. Read API Reference to get more information.

http []

Does a HTTP request.

{
    "deploy": {
        "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
options The value or object for the body script.
password The password for basic authentication.
url The value or object for the body script.
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 HttpBodyModuleExecutorArguments interface.

open []

Opens a target, like an executable or a website.

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

                "deployed": [
                    {
                        "type": "open",
                        "target": "https://github.com/mkloubert"
                    }
                ]
            }
        ]
    }
}
Name Description
arguments** A list of one or more optional arguments for the execution.
envVars An object that defines environment variables for the new process by properties.
noPlaceholdersForTheseVars Defines a list of one or more environment variables that should NOT use placeholders. You also can define (true) to deactivate the feature for all variables.
runInTerminal Run in integrated terminal or not. Default: (false)
target* The thing that should be opened. Can be a URL, file or executable.
useEnvVarsOfWorkspace Also use environment variables of the process of current workspace or not. Default: (false)
usePlaceholdersInArguments Use placeholders in arguments or not. Default: (false)
wait Wait until execution has been finished or not. Default: (true)

* supports placeholders
** supports placeholders, but NOT by default

script []

Runs a script from a file.

{
    "deploy": {
        "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. DeployScriptOperationArguments

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

vscommand []

Executes a Visual Studio Code command.

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

                "beforeDeploy": [
                    {
                        "type": "vscommand",
                        "command": "workbench.action.tasks.build"
                    }
                ]
            }
        ]
    }
}
Name Description
arguments One or more optional argument for the execution.
command The ID of the command to execute.
contextOptions Options for the operation context object (s. submitContext).
submitContext Submit an operation context object as first argument or not (s. DeployVSCommandOperationContext). Default: (false)

wait []

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

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

webdeploy []

Executes Microsoft's Web Deploy tool (msdeploy).

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

                "deployed": [
                    {
                        "type": "webdeploy",
                        "exec": "C:/Program Files/IIS/Microsoft Web Deploy V3/msdeploy.exe",

                        "verb": "sync",
                        "source": "contentPath=c:\\sourcedir",
                        "dest": "contentPath=c:\\newdir",
                        "whatif": true
                    }
                ]
            }
        ]
    }
}

This example represents the following execution from command line:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:contentPath=c:\sourcedir -dest:contentPath=c:\newdir -whatif
Name Description
allowUntrusted When specified, untrusted SSL connections are allowed; otherwise, untrusted SSL Connections are not allowed. Default: (false)
appHostConfigDir Specifies the path of the ApplicationHost.config file for the current instance of IIS Express.
args One or more additional arguments for the execution.
declareParam Creates a user-specified parameter for a package or archive. When the package or archive is later synchronized, the value of the declared parameter is specified by using setParam.
declareParamFile Specifies an XML file that contains declarations of parameters that will be used in an operation. The XML format of the declared parameters matches that of the parameters that are found in the archive or package.
dest Specifies the destination (the target object) of the operation that the verb argument specifies. The and its associated settings more narrowly define the destination object or how it will be processed.
dir The custom working directory for the execution.
disableAppStore Default: (false)
disableLink Disables one or more specified link extensions during a synchronization operation. The link extensions are specified after disableLink in a comma-delimited list. You can specify the link extension names directly, or use regular expressions that resolve to valid Web Deploy link extension names.
disableRule Disables the specified synchronization rule or rules during a synchronization operation. The rules are specified after disableRule in a comma-delimited list. You can specify the rule names directly, or use a regular expression that resolves to valid Web Deploy rules. The specified rule name can also be followed by an asterisk wildcard character.
disableSkipDirective Disables the specified skip directive.
enableLink Enables one or more specified link extensions during a synchronization operation. The link extensions are specified after enableLink in a comma-delimited list. You can specify the link extension names directly, or use regular expressions that resolve to valid Web Deploy link extension names.
enableRule Enables one or more synchronization rules during a synchronization operation. The rules are specified after enableRule in a comma-delimited list. You can specify the rule names directly, or use a regular expression that resolves to valid Web Deploy rules. The specified rule name can also be followed by an asterisk wildcard character.
envVars An object that defines environment variables for the new process by properties.
exec The path of the executable. Default: msdeploy.exe
noPlaceholdersForTheseVars Defines a list of one or more environment variables that should NOT use [[placeholders
postSync Runs the specified command or batch file on the destination after a synchronization completes.
preSync Runs the specified command or batch file on the destination before a synchronization starts.
removeParam Removes a parameter definition from the list of declared parameters.
replace Specifies items to replace during a synchronization operation. More than one replace argument can appear on the same command line.
retryAttempts Specifies the number of times the provider will retry after a failure.
retryInterval Specifies, in milliseconds, the interval between provider retry attempts.
runInTerminal Run in integrated terminal or not. Default: (false)
setParam Specifies values during a sync operation for the parameters that you specify.
setParamFile Applies parameter settings from an XML "answer" file during a sync operation.
showSecure When specified, displays encrypted configuration properties (such as passwords) in clear text when the output format is XML. Default: (false)
skip Specifies an action or object to be excluded during a synchronization operation.
source Specifies the source of the data for the operation that the verb argument specifies.
unicode Specifies that the string values for the username and password provider settings will be encoded in UTF-8. Default: (false)
useCheckSum Specifies that files will be compared by using their CRC (Cyclic Redundancy Check) checksum and ignoring their last write time. Default: (false)
useEnvVarsOfWorkspace Also use environment variables of the process of current workspace or not. Default: (false)
verb Specifies the action that the operation will perform.
verbose Specifies that the Informational verbosity level will be included in the output of the operation. Default: (false)
wait Wait until execution has been finished or not. Default: (true)
webServerDir Specifies the path of the program files for the current instance of IIS Express.
whatif Specifies that the command will be run without actually making any changes. Default: (false)
xml Specifies that the output should be returned in XML format. Default: (false)
xpath Specifies an XPath expression to apply to XML output.