add functionality

This commit is contained in:
Philipp Kunz 2016-05-30 02:28:47 +02:00
parent d82e28f5d1
commit c13ab8e428
8 changed files with 97 additions and 11 deletions

32
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,32 @@
image: hosttoday/ht-docker-node
stages:
- test
- release
testLTS:
stage: test
script:
- npmci install 4
- npm install
- npm test
tags:
- docker
testSTABLE:
stage: test
script:
- npmci install stable
- npm install
- npm test
tags:
- docker
release:
stage: release
script:
- npm -v
only:
- tags
tags:
- docker

View File

@ -0,0 +1 @@
{}

View File

@ -25,6 +25,7 @@
"dependencies": { "dependencies": {
"beautylog": "^5.0.6", "beautylog": "^5.0.6",
"commander": "^2.9.0", "commander": "^2.9.0",
"q": "^1.4.1",
"shelljs": "^0.7.0", "shelljs": "^0.7.0",
"smartfile": "^3.0.10", "smartfile": "^3.0.10",
"typings-global": "^1.0.3" "typings-global": "^1.0.3"

View File

@ -2,6 +2,9 @@
import "typings-global"; import "typings-global";
import * as plugins from "./npmci.plugins"; import * as plugins from "./npmci.plugins";
import {install} from "./npmci.install";
import {test} from "./npmci.test";
import {publish} from "./npmci.publish";
let command; let command;
@ -9,10 +12,10 @@ let commandOption;
plugins.commander plugins.commander
.version('0.0.1') .version('0.0.1')
.arguments('<cmd> [node]') .arguments('<commandarg> [commandoptionarg]')
.action(function (commandArg, commandOptionArg) { .action(function (commandarg, commandoptionarg) {
command = commandArg; command = commandarg;
commandOption = commandOptionArg; commandOption = commandoptionarg;
}); });
plugins.commander.parse(process.argv); plugins.commander.parse(process.argv);
@ -24,7 +27,15 @@ if (typeof command === 'undefined') {
switch (command){ switch (command){
case "install": case "install":
install(commandOption);
break;
case "test":
test(commandOption);
break;
case "publish":
publish();
break;
default:
break;
} }
shelljs.exec("bash -c \"source /usr/local/nvm/nvm.sh && nvm install "+ commandOption + " nvm alias default " + commandOption + "\"");

View File

@ -1,3 +1,22 @@
import "typings-global";
import * as plugins from "./npmci.plugins";
export let install = (versionArg) => { export let install = (versionArg) => {
if(versionArg = ) let done = plugins.q.defer();
let version:string;
if(versionArg = "lts"){
version = "4";
} else {
version = versionArg;
};
plugins.beautylog.log("now installing " + "node ".green + ("version " + version).yellow);
plugins.shelljs.exec(
"bash -c \"source /usr/local/nvm/nvm.sh && nvm install "+
version +
" nvm alias default " +
version +
"\""
);
plugins.beautylog.success("Node version " + version + " successfully installed!");
done.resolve();
return done.promise;
} }

View File

@ -1,4 +1,6 @@
import "typings-global"; import "typings-global";
export import beautylog = require("beautylog"); export import beautylog = require("beautylog");
export let commander = require("commander"); export let commander = require("commander");
export let q = require("q");
export let shelljs = require("shelljs"); export let shelljs = require("shelljs");
export import smartfile = require("smartfile");

View File

@ -1,6 +1,15 @@
import "typings-global";
import * as plugins from "./npmci.plugins";
let npmrcPrefix:string = "//registry.npmjs.org/:_authToken="; let npmrcPrefix:string = "//registry.npmjs.org/:_authToken=";
let npmToken:string; let npmToken:string = process.env.NPMCITOKEN;
let npmrcFileString = npmrcPrefix + npmToken;
export let publish = () => { export let publish = () => {
let done = plugins.q.defer();
plugins.smartfile.memory.toFs(npmrcFileString,{fileName:".npmrc",filePath:"/root/"});
plugins.shelljs.exec("npm publish");
return done.promise;
}; };

View File

@ -1,3 +1,14 @@
export let test = () => { import "typings-global";
import * as plugins from "./npmci.plugins";
import {install} from "./npmci.install";
export let test = (versionArg) => {
let done = plugins.q.defer();
install(versionArg)
.then(function(){
plugins.beautylog.info("now starting tests:");
plugins.shelljs.exec("npm test");
plugins.beautylog.success("test finished");
done.resolve();
})
return done.promise;
} }