add prepare command
This commit is contained in:
parent
34f29bb4b4
commit
8fec378a53
@ -28,6 +28,7 @@
|
||||
"q": "^1.4.1",
|
||||
"shelljs": "^0.7.0",
|
||||
"smartfile": "^3.0.10",
|
||||
"smartssh": "^1.0.4",
|
||||
"typings-global": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,12 @@ switch (command){
|
||||
break;
|
||||
case "test":
|
||||
test(commandOption);
|
||||
break;
|
||||
case "prepare":
|
||||
|
||||
break;
|
||||
case "publish":
|
||||
publish();
|
||||
publish(commandOption);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -4,13 +4,15 @@ import {bash} from "./npmci.bash";
|
||||
|
||||
export let install = (versionArg) => {
|
||||
let done = plugins.q.defer();
|
||||
plugins.beautylog.log("now installing " + "node ".green + ("version " + versionArg).yellow);
|
||||
let version:string;
|
||||
if(versionArg == "lts"){
|
||||
version = "4";
|
||||
} else if(versionArg = "legacy"){
|
||||
version = "4.0.0"
|
||||
} else {
|
||||
version = versionArg;
|
||||
};
|
||||
plugins.beautylog.log("now installing " + "node ".green + ("version " + version).yellow);
|
||||
bash(
|
||||
"nvm install " + version +
|
||||
" && nvm alias default " + version
|
||||
|
@ -3,4 +3,5 @@ export import beautylog = require("beautylog");
|
||||
export let commander = require("commander");
|
||||
export let q = require("q");
|
||||
export let shelljs = require("shelljs");
|
||||
export let smartssh = require("smartssh");
|
||||
export import smartfile = require("smartfile");
|
33
ts/npmci.prepare.ts
Normal file
33
ts/npmci.prepare.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./npmci.plugins";
|
||||
|
||||
let docker = function(){
|
||||
|
||||
}
|
||||
|
||||
let npm = function(){
|
||||
let done = plugins.q.defer();
|
||||
|
||||
let npmrcPrefix:string = "//registry.npmjs.org/:_authToken=";
|
||||
let npmToken:string = process.env.NPMCITOKEN;
|
||||
let npmrcFileString = npmrcPrefix + npmToken;
|
||||
|
||||
if(npmToken){
|
||||
plugins.beautylog.info("found access token");
|
||||
} else {
|
||||
plugins.beautylog.error("no access token found! Exiting!");
|
||||
process.exit(1);
|
||||
}
|
||||
plugins.smartfile.memory.toFsSync(npmrcFileString,{fileName:".npmrc",filePath:"/root"});
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
export let prepare = function(serviceArg:string){
|
||||
switch (serviceArg) {
|
||||
case "npm":
|
||||
return npm();
|
||||
case "docker":
|
||||
return docker();
|
||||
}
|
||||
}
|
@ -1,22 +1,42 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./npmci.plugins";
|
||||
import {prepare} from "./npmci.prepare";
|
||||
import {bash} from "./npmci.bash";
|
||||
|
||||
let npmrcPrefix:string = "//registry.npmjs.org/:_authToken=";
|
||||
let npmToken:string = process.env.NPMCITOKEN;
|
||||
let npmrcFileString = npmrcPrefix + npmToken;
|
||||
|
||||
|
||||
export let publish = () => {
|
||||
export let publish = (serviceArg:string = "npm") => {
|
||||
let done = plugins.q.defer();
|
||||
if(npmToken){
|
||||
plugins.beautylog.info("found access token");
|
||||
} else {
|
||||
plugins.beautylog.error("no access token found! Exiting!");
|
||||
process.exit(1);
|
||||
switch (serviceArg){
|
||||
case "npm":
|
||||
publishNpm()
|
||||
.then(function(){
|
||||
done.resolve();
|
||||
});
|
||||
break;
|
||||
case "docker":
|
||||
publishDocker()
|
||||
.then(function(){
|
||||
done.resolve();
|
||||
});
|
||||
}
|
||||
plugins.smartfile.memory.toFsSync(npmrcFileString,{fileName:".npmrc",filePath:"/root"});
|
||||
bash("npm publish");
|
||||
plugins.beautylog.ok("Done!")
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let publishNpm = function(){
|
||||
let done = plugins.q.defer();
|
||||
prepare("npm")
|
||||
.then(function(){
|
||||
bash("npm publish");
|
||||
plugins.beautylog.ok("Done!") ;
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
let publishDocker = function(){
|
||||
let done = plugins.q.defer();
|
||||
prepare("docker")
|
||||
.then(function(){
|
||||
bash("docker push");
|
||||
});
|
||||
return done.promise;
|
||||
};
|
Loading…
Reference in New Issue
Block a user