40 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-04-18 17:24:41 +02:00
/*
* 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.
2020-05-07 18:40:35 +02:00
* Created by Timo Hocker <timo@scode.ovh>, May 2020
2020-04-18 17:24:41 +02:00
*/
import { Confirm } from 'enquirer';
import { Snippet } from '../../Snippet';
import { apply_template, modify_json } from '../../Helper';
2020-04-18 19:00:27 +02:00
import { general, node } from './Assets';
2020-04-18 17:24:41 +02:00
2020-04-18 19:00:27 +02:00
export default class Jenkins implements Snippet {
2020-05-11 12:01:39 +02:00
public is_active (): boolean {
return true;
}
2020-04-18 17:24:41 +02:00
public async start (): Promise<void> {
const is_node = await new Confirm ({
message: 'is the current project using nodejs?',
initial: true
})
.run ();
if (is_node) {
2020-04-18 19:00:27 +02:00
await apply_template (node.js, 'jenkins.js');
await apply_template (node.jenkinsfile, 'Jenkinsfile');
2020-04-18 17:43:13 +02:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await modify_json ((obj: any): any => {
2020-04-18 17:24:41 +02:00
obj.scripts.ci = 'yarn && node jenkins.js';
return obj;
});
}
else {
2020-04-18 19:00:27 +02:00
await apply_template (general.jenkinsfile, 'Jenkinsfile');
2020-04-18 17:24:41 +02:00
}
}
}