adapt to drone
This commit is contained in:
		
							
								
								
									
										20
									
								
								lib/snippets/drone/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								lib/snippets/drone/index.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| /* | ||||
|  * Copyright (C) SapphireCode - All Rights Reserved | ||||
|  * This file is part of Snippeteer which is released under BSD-3-Clause. | ||||
|  * See file 'LICENSE' for full license details. | ||||
|  * Created by Timo Hocker <timo@scode.ovh>, July 2020 | ||||
|  */ | ||||
|  | ||||
| import { files } from '@sapphirecode/standard'; | ||||
| import { Snippet } from '../../Snippet'; | ||||
| import { apply_template } from '../../Helper'; | ||||
|  | ||||
| export default class Drone implements Snippet { | ||||
|   public is_active (): boolean { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   public async start ():Promise<void> { | ||||
|     await apply_template (files.drone, '.drone.yml'); | ||||
|   } | ||||
| } | ||||
| @@ -7,10 +7,7 @@ | ||||
|  | ||||
| /* eslint-disable max-len */ | ||||
|  | ||||
| import { files } from '@sapphirecode/standard'; | ||||
|  | ||||
| const general = { jenkinsfile: '' }; | ||||
| const node = { jenkinsfile: files.jenkinsfile, js: files.jenkins }; | ||||
|  | ||||
| general.jenkinsfile = `pipeline { | ||||
|   agent any | ||||
| @@ -53,4 +50,4 @@ general.jenkinsfile = `pipeline { | ||||
| } | ||||
| `; | ||||
|  | ||||
| export { general, node }; | ||||
| export { general }; | ||||
|   | ||||
| @@ -5,11 +5,10 @@ | ||||
|  * Created by Timo Hocker <timo@scode.ovh>, May 2020 | ||||
|  */ | ||||
|  | ||||
| import { Confirm } from 'enquirer'; | ||||
| import { Snippet } from '../../Snippet'; | ||||
| import { apply_template, modify_json } from '../../Helper'; | ||||
| import { apply_template } from '../../Helper'; | ||||
|  | ||||
| import { general, node } from './Assets'; | ||||
| import { general } from './Assets'; | ||||
|  | ||||
| export default class Jenkins implements Snippet { | ||||
|   public is_active (): boolean { | ||||
| @@ -17,23 +16,6 @@ export default class Jenkins implements Snippet { | ||||
|   } | ||||
|  | ||||
|   public async start (): Promise<void> { | ||||
|     const is_node = await new Confirm ({ | ||||
|       message: 'is the current project using nodejs?', | ||||
|       initial: true | ||||
|     }) | ||||
|       .run (); | ||||
|  | ||||
|     if (is_node) { | ||||
|       await apply_template (node.js, 'jenkins.js'); | ||||
|       await apply_template (node.jenkinsfile, 'Jenkinsfile'); | ||||
|       // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||
|       await modify_json ((obj: any): any => { | ||||
|         obj.scripts.ci = 'yarn && node jenkins.js'; | ||||
|         return obj; | ||||
|       }); | ||||
|     } | ||||
|     else { | ||||
|       await apply_template (general.jenkinsfile, 'Jenkinsfile'); | ||||
|     } | ||||
|     await apply_template (general.jenkinsfile, 'Jenkinsfile'); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user