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: netlify dev --graph: watch config.toml and reload automatically #4268

Merged
merged 15 commits into from
Feb 14, 2022

Conversation

anmonteiro
Copy link
Contributor

🎉 Thanks for submitting a pull request! 🎉

Summary

Fixes https://github.com/netlify/netlify-graph-project-planning/issues/16


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)

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Feb 12, 2022
@github-actions
Copy link

github-actions bot commented Feb 12, 2022

📊 Benchmark results

Comparing with fa3980d

Package size: 442 MB

(no change)

^  439 MB  439 MB  439 MB  439 MB  439 MB  439 MB  439 MB  439 MB  438 MB  438 MB  438 MB  438 MB  442 MB 
│   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

Copy link
Contributor

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

Thanks @anmonteiro, added a comment.

I think it would be better to introduce this functionality only when the graph flag is passed to reduce the risk of this breaking other commands.

src/commands/base-command.js Outdated Show resolved Hide resolved
src/commands/base-command.js Outdated Show resolved Hide resolved
@anmonteiro anmonteiro requested a review from erezrokah February 14, 2022 18:44
const watchDebounced = async (target, { depth, onAdd = () => {}, onChange = () => {}, onUnlink = () => {} }) => {
const watcher = chokidar.watch(target, { depth, ignored: /node_modules/, ignoreInitial: true })

await pEvent(watcher, 'ready')
Copy link
Contributor

Choose a reason for hiding this comment

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

chokidar can emit error events.
Not a blocker for this PR, but we might consider handling those.

erezrokah
erezrokah previously approved these changes Feb 14, 2022
watchDebounced(configPath, {
depth: 1,
onChange: async () => {
const { config: newConfig } = await actionCommand.getConfig({ cwd, state, token, ...apiUrlOpts })
Copy link
Contributor

@ehmicky ehmicky Feb 14, 2022

Choose a reason for hiding this comment

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

Adding/removing/changing a netlify.toml might also modify the buildDir and the configPath returned by actionCommand.getConfig().
In a follow-up PR, we should consider handling this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is very well spotted, and it also looks a little harder than a quickfix. I'm going to open an issue to track it.

ehmicky
ehmicky previously approved these changes Feb 14, 2022
Copy link
Contributor

@ehmicky ehmicky left a comment

Choose a reason for hiding this comment

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

This looks good to me, with some notes for follow-up PRs.
Also, some tests are failing, but I'm unsure whether this is related to this PR or not.

@anmonteiro anmonteiro dismissed stale reviews from ehmicky and erezrokah via 7db9644 February 14, 2022 20:13
ehmicky
ehmicky previously approved these changes Feb 14, 2022
@anmonteiro anmonteiro added the automerge Add to Kodiak auto merge queue label Feb 14, 2022
@kodiakhq kodiakhq bot merged commit d961855 into main Feb 14, 2022
@kodiakhq kodiakhq bot deleted the anmonteiro/watch-config branch February 14, 2022 21:32
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.

5 participants