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

feat: automatically link site post creation #3901

Merged
merged 5 commits into from
Jan 25, 2022

Conversation

ximenasandoval
Copy link
Contributor

@ximenasandoval ximenasandoval commented Dec 22, 2021

🎉 Thanks for submitting a pull request! 🎉

Summary

Fixes #3827

When running the command netlify sites:create the CLI returns a success message with Admin URL, URL and Site ID. If we try to run netlify build we get an error "Could not find site ID. Please run netlify link".

This change runs link after creating a site, as well as adding a flag --disable-linking to sites:create if we want to avoid linking the current directory.

image
image


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

cute cat

@ximenasandoval ximenasandoval requested a review from a team as a code owner December 22, 2021 19:58
@ximenasandoval ximenasandoval changed the title feat: automatically link site post creation (#3827) feat: automatically link site post creation Dec 22, 2021
@erezrokah erezrokah added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Dec 23, 2021
Copy link
Collaborator

@lukasholzer lukasholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review but we where discussing this issue internally. But I think this solution should work pretty fine!

I tested it out and it is a way better DX.

Thanks for your effort and adding the tests 😍 I appreciate this a lot!

@erezrokah would it be a breaking change? As we change the behaviour of the existing link command or can it be seen as feature. Not sure if someone relies on the behaviour of NOT linking the site

}

if (options.id) {
} else if (options.id) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate why you have changed this behaviour?

the exit should be the same behaviour.
IMHO early exits are easier to read then else if statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I removed exit because the sites-create tests were failing since it was calling exit even if everything was okay and made the test fail. By removing the exit function I needed to make sure the other paths of the link command weren't being executed, so I added the else if to the conditions 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I would try to not change the code because of tests.
As the exit function could be mocked in the tests and checked if it would be called.

But this is fine in this case

@lukasholzer lukasholzer added the automerge Add to Kodiak auto merge queue label Jan 25, 2022
@kodiakhq kodiakhq bot merged commit b247e69 into netlify:main Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to Kodiak auto merge queue type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically link a site post creation via CLI
3 participants