npmci/ts/npmci.publish.ts

50 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2016-05-30 00:28:47 +00:00
import "typings-global";
import * as plugins from "./npmci.plugins";
2016-06-01 03:42:37 +00:00
import {prepare} from "./npmci.prepare";
2016-05-30 01:40:07 +00:00
import {bash} from "./npmci.bash";
import * as NpmciEnv from "./npmci.env";
import * as NpmciBuildDocker from "./npmci.build.docker"
2016-05-30 00:28:47 +00:00
/**
* 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){
2016-06-01 03:42:37 +00:00
case "npm":
2016-06-03 01:44:24 +00:00
return publishNpm();
2016-06-01 03:42:37 +00:00
case "docker":
2016-06-03 01:44:24 +00:00
return publishDocker();
2016-06-01 03:42:37 +00:00
}
};
2016-05-30 00:28:47 +00:00
/**
* tries to publish project at cwd to npm
*/
2016-06-01 03:42:37 +00:00
let publishNpm = function(){
let done = plugins.q.defer();
prepare("npm")
.then(function(){
bash("npm publish");
plugins.beautylog.ok("Done!") ;
done.resolve();
});
return done.promise;
}
2016-05-29 20:54:59 +00:00
/**
* tries to pubish current cwd to Docker registry
*/
2016-06-01 03:42:37 +00:00
let publishDocker = function(){
2016-05-30 00:28:47 +00:00
let done = plugins.q.defer();
NpmciBuildDocker.readDockerfiles()
2016-06-07 02:31:25 +00:00
.then(NpmciBuildDocker.pullDockerfileImages)
.then(NpmciBuildDocker.pushDockerfiles)
2016-06-07 02:31:25 +00:00
.then(done.resolve);
2016-05-30 00:28:47 +00:00
return done.promise;
};