happy-deploy
Npm scripts collection to manage deployments
Installation
npm i happy-deploy --save
Methods
- run
- addTask
- git
- getCache
- getConfig
- CompileHaxeTask
- CompassTask
- PackageTask
- SendSSHTask
Usage
var deploy = ; //Include happy-deploy module... deploy; // Add somes tasksdeploy; deploy; // run deploy
addTask
addTask(task)
Add a task to the queue Exemple :
var CompassTask = deployCompassTask;deploy;
run()
Start deployment
The module execute each task in his queue.
git
git.getBranchName()
Return the current branch name
git.getCurrentTag()
Return the current branch tag name or ""
Exemple :
var deploy = ;var currentTag = deploygit;
git.getCommiterName()
Return the name for the last commiter
Exemple :
var deploy = ;var username = deploygit;
git.getCommitHashMessage()
Return the hash and message of last commit.
Exemple :
var deploy = ;var hashMessage = deploygit;
git.getCommitHash()
Return the hash of last commit.
Exemple :
var deploy = ;var hashMessage = deploygit;
git.getRepoUrl()
Return the url of the current repo.
Exemple :
var deploy = ;var repoUrl = deploygit;
git.getRepoName()
Return the name of the current repo.
Exemple :
var deploy = ;var repoName = deploygit;
getCache()
getCache(env)
Return an instance of Cache with 'env' as the target cache
Exemple :
var deploy = ;var cache = deploy;
Cache.flush()
flush()
Save the cache
Cache.setValue()
setValue(key,value)
Save a value to the cache
Cache.getValue()
getValue(key)
Return a data from the cache
If a value is not found, a prompt will ask for it's value and save it.
getConfig()
getConfig(target)
Load a configuration from 'target'.json and return it
Exemple :
var config = deploy;
CompileHaxeTask
CompileHaxeTask(main, output, minify=false)
Create a new instance of CompileHaxeTask.
- @param main //The main class to compile
- @param output //The output file
- @param minify //minify or not
@property dir //the home directory
@property src //src folder list
@property libs //list of haxe libs
@property options //optionnals arguments
@property hxml
Exemple :
var compileDefault = 'DefaultApplication'thisoutput+thisconfigoutputjs+'/DefaultApplication.js'thisconfigminify; compileDefaulthxml = 'compile-default.hxml'; compileDefaultdir = 'heidi'; compileDefaultoptions = '-D this.version='+thisversion+' -D tag='+thiscurrentTag; deploy;
CompassTask
CompassTask(dir)
Create a new instance of CompassTask.
- @param dir //the target directory to compile
PackageTask
PackageTask(dir,file)
Create a new instance of PackageTask.
- @param dir
- @param file
SendSSHTask
SendSSHTask(host, port, user, password, file, destination, extractDestination, sshKeyPass)
Create a new instance of SendSSHTask.
- @param host
- @param port
- @param user
- @param password
- @param file
- @param destination
- @param extractDestination
- @param sshKeyPass // the path to id_rsa (optionnal)
Full Exemple
var deploy = ;var fsx = ;var fs = ;var replace = ; var config = deploy;var cache = deploy; var branchName = deploygit;var version = branchName;var rendererDeployDir = cache;var output = process+'/build/renderer'; fsx;fsx; // Compile Renderervar compileRenderer = 'SakuraRenderer'output+configoutputjs+'/SakuraRenderer.js'false;compileRenderersrc;compileRendererlibs;compileRendererlibs;compileRendererlibs;compileRendererlibs;compileRendererlibs;compileRendererlibs;compileRendererlibs; compileRendererdir = 'sakuraEditor';compileRendereroptions = '-D this.version='+version+' -D tag='+currentTag; deploy; var deployTask = { // Copy render ressources fsx; fsx; fsx; ; forvar i=1; i<9; i++ var destination = rendererDeployDir+'/'+version+'/'+i; ; fsx; fsx; fs; ; ; } deploy; deploy;
ExecSSHTask
ExecSSHTask(host, port, user, password, sshKeyPass, command)
Execute a shell command via ssh
- @param host
- @param port
- @param user
- @param password
- @param sshKeyPass
- @param command
SendFTPTask
SendFTPTask(host, port, user, password, file, destination, extractDestination)
Create a new instance of SendSSHTask.
- @param host
- @param port
- @param user
- @param password
- @param file
- @param destination
- @param extractDestination
Slack
Expose some bin to talk with slack. To execute, add these npm scripts to your package.json :
Note: For the slackdeploy or slackfaildeploy command, you can also pass the
--env=prod
arg. To add this after a deploy:prod, add a script like this :
"postdeploy:prod": "say:deploy -- --env=prod",