Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helpful message about installing git during blitz new if it doesn't exist #489

Closed
aem opened this issue May 1, 2020 · 5 comments
Closed

Comments

@aem
Copy link
Contributor

aem commented May 1, 2020

What is the problem?

@peaonunes pointed out here that we don't error out if any of the git steps fail, so I wanted to open it for discussion. Basically, if any step of the git initialization process fails we still exit with a success code and the resulting output could be not committed to git, or potentially even the repository initialization itself could have failed.

While all of these are bad, I don't know that it's worth bailing out of the installation. With the changes in blitz-js/blitz#367 we'd end up skipping dependency initialization and the initial commit to the repo. Either of those not happening isn't great, but they're also not irrecoverable errors. In fact, it might create more confusion if we successfully generate files, but then show an error and exit with a non-zero exit code - it'll leave a user wondering "what broke?"

Instead I still think we should update the code, but instead track which steps failed and just show extra "getting started" steps in the event that any of those extra bits fails. Right now the final output just alerts the user to cd into the project and run blitz start, but we could prepend items to that list with a brief explanation in the event that an earlier step fails. Say the git init command fails, we could print something like this:

We were unable to initialize your git repository - the error message is printed above. To finish setup, please run:
   1. cd my-app
   2. git init && git commit -a -m 'first Blitz commit!'

Then, to get started:
   1. blitz start
   2. You create new pages by placing components inside app/pages/

Thoughts?

@flybayer
Copy link
Member

flybayer commented May 1, 2020

I totally agree that any non-critical failure (like git, pkg installation, etc) should not fail the entire process. Showing a helpful message about what we couldn't do is fantastic.

For git specifically, it probably means git isn't installed, so we should add instructions/link on how to do that.

@peaonunes
Copy link
Contributor

Yeah, I do think it is not critical for the new app to be able to run. Some tools like husky will be configured, but not work anyway. We could look for inspirations in other clis, but a helpful error message with instructions may be enough for now.

@aem
Copy link
Contributor Author

aem commented May 1, 2020

For git specifically, it probably means git isn't installed

We should absolutely be able to test for this and show install helpers. Like that a lot

@peaonunes
Copy link
Contributor

To verify the existence of installed clis it would require a bash script like:

git --version 2>&1 >/dev/null # improvement by tripleee
GIT_IS_AVAILABLE=$?
# ...
if [ $GIT_IS_AVAILABLE -eq 0 ]; then #...

ref: https://stackoverflow.com/questions/7292584/how-to-check-if-git-is-installed-from-bashrc
In the meantime I've added a link to download git if the git init fails on this PR blitz-js/blitz@71d38f4.

@flybayer flybayer changed the title Failed git setup doesn't fail the blitz new command Add helpful message about installing git during blitz new if it doesn't exist May 5, 2020
@aem aem closed this as completed Jul 12, 2020
@dillondotzip dillondotzip transferred this issue from blitz-js/blitz Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants