create-expo-stack icon indicating copy to clipboard operation
create-expo-stack copied to clipboard

[cli] add option to run setup-ci after project is created

Open km1chno opened this issue 1 year ago • 4 comments

Description

This PR is a proposition of how create-expo-stack could integrate with setup-ci. It adds a prompt asking the user whether they want to bootstrap CI using setup-ci after the project is created and runs setup-ci in a subprocess at the end if the answer was "Yes".

Some details:

  • we don't add the setup-ci option to config, therefore the prompt appears after the user is asked whether they want to save their configuration,
  • the prompt only appears if noInstall == false, noGit == false and packageManager is yarn or npm, these are requirements for setup-ci to work in the generated project,
  • if the user decides to run setup-ci, an env variable is set process.env.RUN_SETUP_CI = 'true', which is later read to decide whether the script should be run - this way we don't add new fields to cliResults, which would in turn alter the project configuration interface.

Demo

https://github.com/user-attachments/assets/5e8a1084-0fd4-4a3c-9cbd-6a0076bb3d9e

How Has This Been Tested?

  • create-expo-stack version: 2.11.24
  • setup-ci version: 0.6.0
  • OS: macOS Sonoma 14.7

Verified that npx setup-ci finishes execution successfully and generates all CI workflows when run on projects created with create-expo-stack using following configurations.

npx create-expo-stack@latest project1 --nativewindui
npx create-expo-stack@latest project2 --react-navigation --tabs --restyle --supabase  --eas
npx create-expo-stack@latest project3 --stylesheet --firebase --yarn
npx create-expo-stack@latest project4 --expo-router --unistyles --supabase --yarn --eas

km1chno avatar Oct 30 '24 08:10 km1chno

this is on my radar will get to it soon.

Initial thoughts are that I think we can ditch the env var and just let it be an extra prompt like the others

For right now we should just worry about getting it into the cli. We are actively considering other approaches to reduce the number of prompts, but that should be a separate concern.

I realise we were the ones to bring up that concern so sorry if thats confusing 😅

dannyhw avatar Oct 30 '24 11:10 dannyhw

thanks for your initial thoughts!

There is a prompt, but the env variable is there to move the information whether setup-ci should be run (whether the answer to the prompt was "Yes") from runCLI.ts to printOutput.ts - this is an alternative to the general approach in CES which seems to be to store such info in CliResults. The problem with that is that it extends the cliResults type which I believe automatically extends the interface of the config that users can save and reuse?

I wanted to avoid getting setup-ci in the config, that's why the setup-ci prompt is after the "Would you like to save this configuration for future use?" prompt. Unless you think it's fine to extend this interface?

km1chno avatar Nov 04 '24 08:11 km1chno

oh ok interesting, didn't realise that. I will have to check again to see what you mean about the interface

dannyhw avatar Nov 04 '24 10:11 dannyhw

i'm going to dig into this this week

danstepanov avatar Mar 16 '25 07:03 danstepanov