| 
									
										
										
										
											2016-11-24 23:21:40 +01:00
										 |  |  | import * as plugins from './npmci.plugins' | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  | import { prepare } from './npmci.prepare' | 
					
						
							|  |  |  | import { bash } from './npmci.bash' | 
					
						
							| 
									
										
										
										
											2016-11-24 23:21:40 +01:00
										 |  |  | import * as NpmciEnv from './npmci.env' | 
					
						
							|  |  |  | import * as NpmciBuildDocker from './npmci.build.docker' | 
					
						
							| 
									
										
										
										
											2016-05-30 02:28:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * type of supported services | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  | export type TPubService = 'npm' | 'docker' | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * the main exported publish function. | 
					
						
							| 
									
										
										
										
											2016-09-04 16:05:47 +02:00
										 |  |  |  * @param pubServiceArg references targeted service to publish to  | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  | export let publish = async (pubServiceArg: TPubService = 'npm') => { | 
					
						
							|  |  |  |   switch (pubServiceArg) { | 
					
						
							|  |  |  |     case 'npm': | 
					
						
							|  |  |  |       return await publishNpm() | 
					
						
							|  |  |  |     case 'docker': | 
					
						
							|  |  |  |       return await publishDocker() | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-11-24 23:21:40 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-05-30 02:28:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2016-09-04 16:05:47 +02:00
										 |  |  |  * tries to publish current cwd to NPM registry | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  | let publishNpm = async () => { | 
					
						
							|  |  |  |   await prepare('npm') | 
					
						
							|  |  |  |     .then(async function () { | 
					
						
							|  |  |  |       await bash('npm publish') | 
					
						
							|  |  |  |       plugins.beautylog.ok('Done!') | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2016-06-01 05:42:37 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-05-29 22:54:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * tries to pubish current cwd to Docker registry | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  | let publishDocker = async () => { | 
					
						
							|  |  |  |   return await NpmciBuildDocker.readDockerfiles() | 
					
						
							|  |  |  |     .then(NpmciBuildDocker.pullDockerfileImages) | 
					
						
							|  |  |  |     .then(NpmciBuildDocker.pushDockerfiles) | 
					
						
							|  |  |  |     .then(dockerfileArray => { | 
					
						
							|  |  |  |       return dockerfileArray | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2016-11-24 23:21:40 +01:00
										 |  |  | } |