bosco icon indicating copy to clipboard operation
bosco copied to clipboard

bosco cdn --watch

Open cliftonc opened this issue 9 years ago • 4 comments

Given I now better understand how we're configuring our services (at least today!), the current 'watch for ready text' approach is doomed to fail.

There appears to be no way in gulp (at least) to ensure that you always have the same text output as the final line once a build is finished.

The biggest impact is that the initial run of the cdn command doesn't know when a watched build is done (and so to start serving assets), and on subsequent builds the live-reload plugin doesn't reload the browser if it doesn't know when the build is finished.

I'm considering a few options:

  1. Just make watches verbose, so you can see when they are done - but have the initial build return straight away. After that have no timeouts or anything else, just have the user look at the output.
  2. Rather than watch for specific text, wait for there to be no stdout for a time ... e.g. assume it being quiet for a time means it is finished. Clearly problem with this is long tasks - e.g. css on site-assets takes 5 seconds, so you'd have to look for a delay longer than that (slowing everything down).
  3. Continue to look for text, but introduce a 'debounce' to avoid it saying build started/finished when it isn't really. This supports the current model in app-resource, you get a few false positives but it sort of works.
  4. Switch to web-pack ? No idea if it can be more structured.
  5. Fix gulp somehow?
  6. Have bosco not run the watch cmd, but make you do that yourself manually via the CLI and just have bosco serve from the dist folder.

@bettiolo @geophree thoughts?

cliftonc avatar Sep 28 '16 09:09 cliftonc

  1. The user will still have to look at the output to know when to try the changes. Live reload may help, but you still want to try your changes after the reload happened.
  2. 😭😭😭

What about making bosco run the watch command, piping it to the screen and just updating CDN when the files mentioned in bosco-service.json get updated? This would made the code for the watch functionality so much simpler.

That could be done by nodemon watching the files of bosco-service.json and triggering the CDN refresh.

bettiolo avatar Sep 28 '16 11:09 bettiolo

There is no CDN refresh anymore, bosco just serves whatever is on disk - it doesn't watch any files anymore, that is what it used to do which was a pain in the a**.

Making it pipe the output is exactly what '--verbose' does - hence my suggestion of just making watch commands verbose by default.

The only time a callback really matters is for the first load - where at the moment it wait until all the builds have 'finished' before the CDN starts serving at all.

cliftonc avatar Sep 28 '16 12:09 cliftonc

Fantastic!

Ok, make sense. I think that watch should be verbose by -v|--verbose flag, so it is consistent with the rest. If a developer doesn't care about the watch output we shouldn't force them to see it (except on stderr)

bettiolo avatar Sep 28 '16 12:09 bettiolo

Webpack will always include the name of your bundled file when it's finished a build:

screen shot 2016-10-04 at 12 14 57

We're keying off that file name to indicate that the watch command is ready, which seems to be working very well.

sometimeskind avatar Oct 04 '16 11:10 sometimeskind