-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(www): fail early so it's clearer something is broken! #8700
Conversation
cc @LekoArts |
www/gatsby-node.js
Outdated
@@ -14,7 +14,7 @@ require(`dotenv`).config({ | |||
path: `.env.${process.env.NODE_ENV}`, | |||
}) | |||
|
|||
if (process.env.NODE_ENV === `production` && !process.env.GITHUB_API_TOKEN) { | |||
if (!process.env.GITHUB_API_TOKEN) { | |||
throw new Error( | |||
`A GitHub token is required to build the site. Check the README.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe www/README
to make it more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're in www, I don't know if this is clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But sure! Not too opinionated either way 👍
docs/docs/how-to-contribute.md
Outdated
@@ -91,6 +91,7 @@ To add a new blog post to the gatsbyjs.org blog: | |||
|
|||
- Clone [the Gatsby repo](https://github.com/gatsbyjs/gatsby/) and navigate to `/www` | |||
- Run `yarn` to install all of the website's dependencies. | |||
- Create a `.env.development` file with a `GITHUB_API_TOKEN` environment variable. See [www/README.md](https://github.com/gatsbyjs/gatsby/tree/master/www#working-with-the-starter-showcase) for more info! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also add that to the documentation
part above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need reusable fragments 🙃 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the state here is actually broken. Tagging in @amberleyromo since she created this workflow.
throw new Error( | ||
`A GitHub token is required to build the site. Check the README.` | ||
`A GitHub token is required to build the site. Check www/README.md.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amberleyromo built this so the starter library wouldn’t crash local dev for someone working on something that's not the starter library.
I think that's a good pattern, because getting a GitHub token for an unrelated part of the site you're working on feels like a decent-sized hurdle.
Maybe we can log a better warning about why a GitHub token is required, and let people know they can safely ignore if they're not working on the starter library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was writing out exactly this comment, thank you @jlengstorf 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlengstorf @amberleyromo this fails for me regardless of which section I'm working on. Does it not for you?
See #5073 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to provide some suggestions, but don't want it to block anything.
@@ -76,6 +76,7 @@ a pull request. | |||
|
|||
- Clone the repo and navigate to `/www` | |||
- Run `yarn` to install all of the website's dependencies. | |||
- Create a `.env.development` file with a `GITHUB_API_TOKEN` environment variable. See [www/README][www-readme] for more info! | |||
- Run `gatsby develop` to preview the website in `http://localhost:8000` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to yarn develop
so that it uses the local version of gatsby-cli
instead. I was going to do a PR to fix this, but easier to do all at once. :)
@@ -91,6 +92,7 @@ To add a new blog post to the gatsbyjs.org blog: | |||
|
|||
- Clone [the Gatsby repo](https://github.com/gatsbyjs/gatsby/) and navigate to `/www` | |||
- Run `yarn` to install all of the website's dependencies. | |||
- Create a `.env.development` file with a `GITHUB_API_TOKEN` environment variable. See [www/README][www-readme] for more info! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's less welcoming to new contributors to have to go to multiple sources to understand the contributing instructions. Can we make this easier for people by putting all the instructions in one place?
@LekoArts adding the token solved your issue? #8693 (comment) What I would like to fix here is why lacking the token caused the issue you reported in the other PR. It should just quietly set default empty values for the missing Github info |
@amberleyromo @jlengstorf @LekoArts let's close this in favor of fixing the underlying issue (e.g. default to null/empty fields without a Github token) rather than adding extra hoops :) |
@amberleyromo Actually I doesn't work with the |
@LekoArts heh, it worked for me 🙃 You get the same error? |
@LekoArts I'll look into why this is failing for you. If you figure out why it's not working, PR welcome! :) |
@DSchau @amberleyromo Deleted my |
Related to #5073
This fails earlier (i.e. in dev/prod/any environment) if the necessary environment variable doesn't exist.