From e9199f6630b61624b4549e99eb53676af2f8685c Mon Sep 17 00:00:00 2001 From: Katzper Michno Date: Thu, 19 Sep 2024 14:27:12 +0000 Subject: [PATCH] chore: print warning logs about overwritten workflows (#114) * chore: print warning logs about overwritten workflows * Update readme.md * Update readme.md Co-authored-by: Maciej Stosio --------- Co-authored-by: Maciej Stosio --- readme.md | 3 +++ src/extensions/workflows.ts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/readme.md b/readme.md index b3309f4..cdd026b 100644 --- a/readme.md +++ b/readme.md @@ -18,6 +18,9 @@ then select the setup that matches your project - `npx setup-ci` generates workf If your project has a monorepo structure, run the script from the root directory of the app for which you want to set up workflows. +> [!WARNING] +> If you re-run `npx setup-ci` in the same project or already have some workflows set up manually, they might get overwritten. Therefore, we recommend running the script with no uncommitted changes, so you can easily inspect the diff after script execution. + ## 💡 Demo Say we want to set up GitHub actions that run Typescript and Prettier checks on our project every time we create or push to an existing Pull Request. diff --git a/src/extensions/workflows.ts b/src/extensions/workflows.ts index b1fdd73..ba2a790 100644 --- a/src/extensions/workflows.ts +++ b/src/extensions/workflows.ts @@ -45,6 +45,12 @@ module.exports = (toolbox: CycliToolbox) => { workflowFileName ) + if (toolbox.filesystem.exists(target)) { + toolbox.interactive.warning( + `Workflow file ${workflowFileName} already exists and will be overwritten.` + ) + } + toolbox.filesystem.write(target, workflowString) toolbox.interactive.step(`Created ${workflowFileName} workflow file.`)