Skip to content

Commit 0e48a20

Browse files
committed
dynamically Create CI files with prompt
1 parent 0cc0a08 commit 0e48a20

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/lib/answerHandlers/createNewProjectFiles.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,29 @@ export class CreateNewProjectFiles {
100100
);
101101
}
102102
//endregion
103+
//region cicd template files
104+
const eslint = this.answers['project-additional-dependencies'].includes('eslint');
105+
const testing = this.answers['project-testing-dependencies'].length > 0;
106+
let templateFile = 'only';
107+
if (testing) templateFile = 'test';
108+
if (eslint) templateFile = 'eslint';
109+
if (testing && eslint) templateFile = 'eslint_test';
110+
if (this.answers['project-cicd-pipeline'] !== 'none') {
111+
if (this.answers['project-cicd-pipeline'] === 'github')
112+
fs.mkdirSync(path.join(this.path, '.github', 'workflows'), { recursive: true });
113+
fs.copyFileSync(
114+
path.join(
115+
this.staticPath,
116+
'cicd',
117+
this.answers['project-type'] === 'npm-package' ? 'npm_package' : 'docker',
118+
`${this.answers['project-cicd-pipeline'] === 'github' ? 'github' : 'gitlab'}_build_${templateFile}.yml`
119+
),
120+
this.answers['project-cicd-pipeline'] === 'github'
121+
? path.join(this.path, '.github', 'workflows', 'ci.yml')
122+
: path.join(this.path, '.gitlab-ci.yml')
123+
);
124+
}
125+
//endregion
103126
// copy winston file
104127
if (this.answers['project-additional-dependencies'].includes('winston')) {
105128
fs.copyFileSync(path.join(this.staticPath, 'ts', 'logger.ts'), path.join(this.path, 'src', 'logger.ts'));

0 commit comments

Comments
 (0)