As the document said, The firebase init hosting:github should only run on the project that is already setup Hosting.
But many of us mis-read the document and try to run it on the 1st setup instead.
The CLI should throw a user-friendly message when the user tries to run firebase init hosting:github on a project that has not setup with Hosting
[REQUIRED] Steps to reproduce
Create an empty folder or bootstrap with create-react-app
Run firebase init hosting:github
[REQUIRED] Expected behavior
The CLI should bail out with a user-friendly message because the project is not setup with Hosting
[REQUIRED] Actual behavior
The CLI throw an error after generate Service Account and push into Github Secret
✔ Created service account github-action-336487343 with Firebase Hosting admin permissions.
✔ Uploaded service account JSON to GitHub as secret FIREBASE_SERVICE_ACCOUNT_EXPERIMENT_49E67.
i You can manage your secrets at https://github.com/devpeerapong/firebase-init-hosting-error/settings/secrets.
Error: An unexpected error has occurred.
As you can see, The error message is not very helpful at all.
Running with --debug show us this
[2021-02-07T04:02:16.951Z] TypeError: Cannot read property 'predeploy' of undefined
at Object.initGitHub [as hosting:github] (/Users/peerapong/github.com/devpeerapong/firebase-tools/lib/init/features/hosting/github.js:61:30)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async init (/Users/peerapong/github.com/devpeerapong/firebase-tools/lib/init/index.js:19:9)
The CLI tries to get the predeploy from the Hosting config that's not exist.
I suggest that we bail out early when the command is run on the project that has not setup with Hosting with a message that direct the user to use init hosting.