2017-05-19 10:09:33 +00:00
|
|
|
import * as plugins from './mod.plugins'
|
|
|
|
import { bash } from '../npmci.bash'
|
|
|
|
import * as NpmciEnv from '../npmci.env'
|
|
|
|
|
|
|
|
import * as npmciMods from '../npmci.mods'
|
|
|
|
|
|
|
|
// import interfaces
|
|
|
|
import { Dockerfile } from '../mod_docker/index'
|
|
|
|
|
2016-05-30 00:28:47 +00:00
|
|
|
|
2016-09-04 11:42:22 +00:00
|
|
|
/**
|
|
|
|
* type of supported services
|
|
|
|
*/
|
2017-03-08 13:50:41 +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
|
|
|
*/
|
2017-03-08 13:50:41 +00:00
|
|
|
export let publish = async (pubServiceArg: TPubService = 'npm') => {
|
|
|
|
switch (pubServiceArg) {
|
|
|
|
case 'npm':
|
|
|
|
return await publishNpm()
|
|
|
|
case 'docker':
|
|
|
|
return await publishDocker()
|
|
|
|
}
|
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
|
|
|
*/
|
2017-03-08 13:50:41 +00:00
|
|
|
let publishNpm = async () => {
|
2017-05-19 10:09:33 +00:00
|
|
|
let modPrepare = await npmciMods.modPrepare.load()
|
|
|
|
await modPrepare.prepare('npm')
|
|
|
|
await bash('npm publish')
|
|
|
|
plugins.beautylog.ok('Done!')
|
2016-06-01 03:42:37 +00:00
|
|
|
}
|
2016-05-29 20:54:59 +00:00
|
|
|
|
2016-09-04 11:42:22 +00:00
|
|
|
/**
|
2017-05-18 20:40:09 +00:00
|
|
|
* tries to publish current cwd to Docker registry
|
2016-09-04 11:42:22 +00:00
|
|
|
*/
|
2017-03-08 13:50:41 +00:00
|
|
|
let publishDocker = async () => {
|
2017-05-19 10:09:33 +00:00
|
|
|
let modDocker = await npmciMods.modDocker.load()
|
|
|
|
return await modDocker.readDockerfiles()
|
|
|
|
.then(modDocker.pullDockerfileImages)
|
|
|
|
.then(modDocker.pushDockerfiles)
|
2017-03-08 13:50:41 +00:00
|
|
|
.then(dockerfileArray => {
|
|
|
|
return dockerfileArray
|
|
|
|
})
|
2016-11-24 22:21:40 +00:00
|
|
|
}
|