| 
									
										
										
										
											2017-05-19 12:09:33 +02: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 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-07-27 14:20:56 +02:00
										 |  |  | export let publish = async (argvArg: any) => { | 
					
						
							|  |  |  |   let whatToPublish = argvArg._[1] | 
					
						
							|  |  |  |   switch (whatToPublish) { | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  |     case 'docker': | 
					
						
							| 
									
										
										
										
											2017-07-27 14:20:56 +02:00
										 |  |  |       return await publishDocker(argvArg) | 
					
						
							| 
									
										
										
										
											2017-07-27 21:51:38 +02:00
										 |  |  |     case 'npm': | 
					
						
							|  |  |  |       return await publishNpm(argvArg) | 
					
						
							|  |  |  |     default: | 
					
						
							| 
									
										
										
										
											2017-07-28 01:11:55 +02:00
										 |  |  |       plugins.beautylog.info('no publish target specified, thus defaulting to npm...') | 
					
						
							| 
									
										
										
										
											2017-07-27 21:51:38 +02:00
										 |  |  |       return await publishNpm(argvArg) | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											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-07-27 14:20:56 +02:00
										 |  |  | let publishNpm = async (argvArg) => { | 
					
						
							| 
									
										
										
										
											2017-05-19 12:09:33 +02:00
										 |  |  |   let modPrepare = await npmciMods.modPrepare.load() | 
					
						
							|  |  |  |   await modPrepare.prepare('npm') | 
					
						
							|  |  |  |   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
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2017-05-18 20:40:09 +00:00
										 |  |  |  * tries to publish current cwd to Docker registry | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-07-27 14:20:56 +02:00
										 |  |  | let publishDocker = async (argvArg) => { | 
					
						
							| 
									
										
										
										
											2017-05-19 12:09:33 +02:00
										 |  |  |   let modDocker = await npmciMods.modDocker.load() | 
					
						
							| 
									
										
										
										
											2017-07-27 14:20:56 +02:00
										 |  |  |   return await modDocker.readDockerfiles(argvArg) | 
					
						
							| 
									
										
										
										
											2017-05-19 12:09:33 +02:00
										 |  |  |     .then(modDocker.pullDockerfileImages) | 
					
						
							|  |  |  |     .then(modDocker.pushDockerfiles) | 
					
						
							| 
									
										
										
										
											2017-03-08 14:50:41 +01:00
										 |  |  |     .then(dockerfileArray => { | 
					
						
							|  |  |  |       return dockerfileArray | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2016-11-24 23:21:40 +01:00
										 |  |  | } |