update docs and comments, add servezone compatibility
This commit is contained in:
@ -40,7 +40,7 @@ export let bash = (commandArg: string, retryArg = 2, bareArg = false) => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugins.beautylog.log("ShellExec would be: " + commandArg.blue)
|
||||
plugins.beautylog.log("ShellExec would be: " + commandArg)
|
||||
}
|
||||
return stdOut;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import { nvmAvailable } from "./npmci.bash"
|
||||
|
||||
export let install = (versionArg) => {
|
||||
let done = plugins.q.defer();
|
||||
plugins.beautylog.log("now installing " + "node ".green + ("version " + versionArg).yellow);
|
||||
plugins.beautylog.log(`now installing node version ${versionArg}`);
|
||||
let version: string;
|
||||
if (versionArg == "stable") {
|
||||
version = "6.3.0";
|
||||
|
@ -11,6 +11,7 @@ export import shelljs = require("shelljs");
|
||||
export import smartcli = require("smartcli");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartparam = require("smartparam");
|
||||
export import smartsocket = require("smartsocket");
|
||||
export import smartssh = require("smartssh");
|
||||
export import smartstring = require("smartstring");
|
||||
export let through2 = require("through2");
|
@ -5,8 +5,17 @@ import {bash} from "./npmci.bash";
|
||||
import * as NpmciEnv from "./npmci.env";
|
||||
import * as NpmciBuildDocker from "./npmci.build.docker"
|
||||
|
||||
export let publish = (serviceArg:string = "npm") => {
|
||||
switch (serviceArg){
|
||||
/**
|
||||
* type of supported services
|
||||
*/
|
||||
export type registryService = "npm" | "docker";
|
||||
|
||||
/**
|
||||
* the main exported publish function.
|
||||
* @param registryServiceArg the serviceArg
|
||||
*/
|
||||
export let publish = (registryServiceArg:registryService = "npm") => {
|
||||
switch (registryServiceArg){
|
||||
case "npm":
|
||||
return publishNpm();
|
||||
case "docker":
|
||||
@ -14,6 +23,9 @@ export let publish = (serviceArg:string = "npm") => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* tries to publish project at cwd to npm
|
||||
*/
|
||||
let publishNpm = function(){
|
||||
let done = plugins.q.defer();
|
||||
prepare("npm")
|
||||
@ -25,6 +37,9 @@ let publishNpm = function(){
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* tries to pubish current cwd to Docker registry
|
||||
*/
|
||||
let publishDocker = function(){
|
||||
let done = plugins.q.defer();
|
||||
NpmciBuildDocker.readDockerfiles()
|
||||
|
32
ts/npmci.servezone.ts
Normal file
32
ts/npmci.servezone.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import * as plugins from "./npmci.plugins";
|
||||
|
||||
/**
|
||||
* servezoneRegex is the regex that parses the servezone connection data
|
||||
* parses strings in the form of "servezone.example.com|3000|somepassword"
|
||||
*/
|
||||
let servezoneRegex = /^(.*)\|(.*)\|(.*)/;
|
||||
|
||||
/**
|
||||
* holds the results of the parsed servezone env string
|
||||
*/
|
||||
let servezoneRegexResultArray = servezoneRegex.exec(process.env.NPMCI_SERVEZONE);
|
||||
|
||||
/**
|
||||
* the data object that is used for the smartsocket client object
|
||||
*/
|
||||
let smartsocketClientConstructorOptions = {
|
||||
alias: "npmci",
|
||||
password: servezoneRegexResultArray[3],
|
||||
port: parseInt(servezoneRegexResultArray[2]),
|
||||
role: "ci",
|
||||
url: servezoneRegexResultArray[1]
|
||||
};
|
||||
|
||||
/**
|
||||
* the main run function to submit a service to a servezone
|
||||
*/
|
||||
export let run = (configArg) => {
|
||||
new plugins.smartsocket.SmartsocketClient(
|
||||
smartsocketClientConstructorOptions
|
||||
);
|
||||
};
|
@ -4,12 +4,15 @@ import * as plugins from "./npmci.plugins";
|
||||
let sshRegex = /^(.*)\|(.*)\|(.*)/
|
||||
let sshInstance:plugins.smartssh.SshInstance;
|
||||
|
||||
/**
|
||||
* checks for ENV vars in form of NPMCI_SSHKEY_* and deploys any found ones
|
||||
*/
|
||||
export let ssh = () => {
|
||||
let done = plugins.q.defer();
|
||||
sshInstance = new plugins.smartssh.SshInstance();
|
||||
sshInstance = new plugins.smartssh.SshInstance(); // init ssh instance
|
||||
plugins.smartparam.forEachMinimatch(process.env,"NPMCI_SSHKEY_*",evaluateSshEnv);
|
||||
if(!process.env.NPMTS_TEST){
|
||||
sshInstance.writeToDisk()
|
||||
sshInstance.writeToDisk();
|
||||
} else {
|
||||
plugins.beautylog.log("In test mode, so not storing SSH keys to disk!");
|
||||
};
|
||||
@ -17,6 +20,9 @@ export let ssh = () => {
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* gets called for each found SSH ENV Var and deploys it
|
||||
*/
|
||||
let evaluateSshEnv = (sshkeyEnvVarArg) => {
|
||||
let resultArray = sshRegex.exec(sshkeyEnvVarArg);
|
||||
let sshKey = new plugins.smartssh.SshKey();
|
||||
@ -37,6 +43,9 @@ let evaluateSshEnv = (sshkeyEnvVarArg) => {
|
||||
sshInstance.addKey(sshKey);
|
||||
};
|
||||
|
||||
/**
|
||||
* checks if not undefined
|
||||
*/
|
||||
let notUndefined = (stringArg:string) => {
|
||||
return (stringArg && stringArg != "undefined" && stringArg != "##");
|
||||
}
|
Reference in New Issue
Block a user