37 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.
* Created by Timo Hocker <timo@scode.ovh>, April 2020
*/
import { Confirm } from 'enquirer';
import { Snippet } from '../../Snippet';
import { apply_template, modify_json } from '../../Helper';
import node_js from './template/node/jenkins.js.asset';
import node_jenkinsfile from './template/node/Jenkinsfile.asset';
import general_jenkinsfile from './template/general/Jenkinsfile.asset';
export 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');
await modify_json ((obj) => {
obj.scripts.ci = 'yarn && node jenkins.js';
return obj;
});
}
else {
await apply_template (general_jenkinsfile, 'Jenkinsfile');
}
}
}