forge icon indicating copy to clipboard operation
forge copied to clipboard

feat: added inquirer as an alternative to --template cli

Open sethcg opened this issue 8 months ago • 1 comments

  • [x] I have read the contribution documentation for this project.
  • [x] I agree to follow the code of conduct that this project follows, as appropriate.
  • [x] The changes are appropriately documented (if applicable).
  • [x] The changes have sufficient test coverage (if applicable).
  • [x] The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

These are my proposed changes to the cli tool.

I added @inquirer/prompts to allow users to run the command, instead of specifying --template the user would be asked a series of questions so they could see the available options.

npx create-electron-app@latest my-app

Here's what it looks like in the console:

cli-improve-1 5

Example of results after completion:

cli-improve-2


Notes:

  • This does not break existing "--template" option of running the command.
  • I included a commented out section regarding frontend frameworks this is so in the future there could be vite-react-typescript, vite-vue-typescript, etc. templates. (referencing #3932)

sethcg avatar May 07 '25 21:05 sethcg

@erickzhao Implemented the mentioned @listr2/prompt-adapter-inquirer in the latest commit. Thank you for the suggestion!

sethcg avatar May 13 '25 19:05 sethcg

@erickzhao Do you know who would have the permission to approve this pull request?

sethcg avatar Jul 17 '25 21:07 sethcg

Hi @sethcg, let me take a look!

erickzhao avatar Jul 24 '25 17:07 erickzhao

@erickzhao Thank you for the review, In my last two commits I addressed your comments.

  • [x] Renamed "build tools" to be "bundler"
  • [x] Renamed "Base" to be "None"
  • [x] Fixed webpack naming conventions
  • [x] Fixed the way default parameters are determined for "skipGit", "force", and "copyCIFiles" options

Commit #1 Commit #2

sethcg avatar Aug 20 '25 01:08 sethcg

Thanks for these changes @sethcg. I have a few UX tweaks that I would suggest. I think it might be easier if I just push these commits up to your branch. Sorry for the delay!

erickzhao avatar Aug 20 '25 21:08 erickzhao

Thanks for these changes @sethcg. I have a few UX tweaks that I would suggest. I think it might be easier if I just push these commits up to your branch. Sorry for the delay!

That would be great!

sethcg avatar Aug 20 '25 21:08 sethcg

Just added commit https://github.com/electron/forge/pull/3933/commits/20823ab9768e25c83a602c4d20aa3aa24b406b6e.

  • prompt only appears if no flags are passed
  • changed the prompt to include other initialization options (skipGit and force)

With this change, we lose the default values passed through commander.js in the --help text, but it's not too confusing because all flags are false by default.

erickzhao avatar Aug 20 '25 22:08 erickzhao