2016-11-24 22:21:40 +00:00
|
|
|
import * as plugins from './npmci.plugins'
|
|
|
|
import {prepare} from './npmci.prepare'
|
|
|
|
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
|
|
|
|
2016-09-04 11:42:22 +00:00
|
|
|
/**
|
|
|
|
* type of supported services
|
|
|
|
*/
|
2016-11-24 22:21:40 +00:00
|
|
|
export type TPubService = 'npm' | 'docker';
|
2016-09-04 11:42:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the main exported publish function.
|
2016-09-04 14:05:47 +00:00
|
|
|
* @param pubServiceArg references targeted service to publish to
|
2016-09-04 11:42:22 +00:00
|
|
|
*/
|
2016-11-24 22:21:40 +00:00
|
|
|
export let publish = (pubServiceArg: TPubService = 'npm') => {
|
|
|
|
switch (pubServiceArg) {
|
|
|
|
case 'npm':
|
|
|
|
return publishNpm()
|
|
|
|
case 'docker':
|
|
|
|
return publishDocker()
|
2016-06-01 03:42:37 +00:00
|
|
|
}
|
2016-11-24 22:21:40 +00:00
|
|
|
}
|
2016-05-30 00:28:47 +00:00
|
|
|
|
2016-09-04 11:42:22 +00:00
|
|
|
/**
|
2016-09-04 14:05:47 +00:00
|
|
|
* tries to publish current cwd to NPM registry
|
2016-09-04 11:42:22 +00:00
|
|
|
*/
|
2016-06-01 03:42:37 +00:00
|
|
|
let publishNpm = function(){
|
2016-11-24 22:21:40 +00:00
|
|
|
let done = plugins.q.defer()
|
|
|
|
prepare('npm')
|
2016-06-01 03:42:37 +00:00
|
|
|
.then(function(){
|
2016-11-24 22:21:40 +00:00
|
|
|
bash('npm publish')
|
|
|
|
plugins.beautylog.ok('Done!')
|
|
|
|
done.resolve()
|
|
|
|
})
|
|
|
|
return done.promise
|
2016-06-01 03:42:37 +00:00
|
|
|
}
|
2016-05-29 20:54:59 +00:00
|
|
|
|
2016-09-04 11:42:22 +00:00
|
|
|
/**
|
|
|
|
* tries to pubish current cwd to Docker registry
|
|
|
|
*/
|
2016-06-01 03:42:37 +00:00
|
|
|
let publishDocker = function(){
|
2016-11-24 22:21:40 +00:00
|
|
|
let done = plugins.q.defer()
|
2016-06-05 20:51:59 +00:00
|
|
|
NpmciBuildDocker.readDockerfiles()
|
2016-06-07 02:31:25 +00:00
|
|
|
.then(NpmciBuildDocker.pullDockerfileImages)
|
2016-06-07 21:21:56 +00:00
|
|
|
.then(NpmciBuildDocker.pushDockerfiles)
|
2016-11-24 22:21:40 +00:00
|
|
|
.then(done.resolve)
|
|
|
|
return done.promise
|
|
|
|
}
|