| 
									
										
										
										
											2016-05-30 02:28:47 +02:00
										 |  |  | import "typings-global"; | 
					
						
							|  |  |  | import * as plugins from "./npmci.plugins"; | 
					
						
							| 
									
										
										
										
											2016-06-01 05:42:37 +02:00
										 |  |  | import {prepare} from "./npmci.prepare"; | 
					
						
							| 
									
										
										
										
											2016-05-30 03:40:07 +02:00
										 |  |  | import {bash} from "./npmci.bash"; | 
					
						
							| 
									
										
										
										
											2016-06-05 05:16:14 +02:00
										 |  |  | import * as NpmciEnv from "./npmci.env"; | 
					
						
							| 
									
										
										
										
											2016-06-05 22:51:59 +02:00
										 |  |  | 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 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-09-04 16:05:47 +02: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
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-09-04 16:05:47 +02:00
										 |  |  | export let publish = (pubServiceArg:TPubService = "npm") => { | 
					
						
							|  |  |  |     switch (pubServiceArg){ | 
					
						
							| 
									
										
										
										
											2016-06-01 05:42:37 +02:00
										 |  |  |         case "npm":  | 
					
						
							| 
									
										
										
										
											2016-06-03 03:44:24 +02:00
										 |  |  |             return publishNpm(); | 
					
						
							| 
									
										
										
										
											2016-06-01 05:42:37 +02:00
										 |  |  |         case "docker": | 
					
						
							| 
									
										
										
										
											2016-06-03 03:44:24 +02:00
										 |  |  |             return publishDocker(); | 
					
						
							| 
									
										
										
										
											2016-06-01 05:42:37 +02: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
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-06-01 05:42:37 +02: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 22:54:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-04 13:42:22 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * tries to pubish current cwd to Docker registry | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-06-01 05:42:37 +02:00
										 |  |  | let publishDocker = function(){ | 
					
						
							| 
									
										
										
										
											2016-05-30 02:28:47 +02:00
										 |  |  |     let done = plugins.q.defer(); | 
					
						
							| 
									
										
										
										
											2016-06-05 22:51:59 +02:00
										 |  |  |         NpmciBuildDocker.readDockerfiles() | 
					
						
							| 
									
										
										
										
											2016-06-07 04:31:25 +02:00
										 |  |  |         .then(NpmciBuildDocker.pullDockerfileImages) | 
					
						
							| 
									
										
										
										
											2016-06-07 23:21:56 +02:00
										 |  |  |         .then(NpmciBuildDocker.pushDockerfiles) | 
					
						
							| 
									
										
										
										
											2016-06-07 04:31:25 +02:00
										 |  |  |         .then(done.resolve); | 
					
						
							| 
									
										
										
										
											2016-05-30 02:28:47 +02:00
										 |  |  |     return done.promise; | 
					
						
							| 
									
										
										
										
											2016-06-05 22:51:59 +02:00
										 |  |  | }; |