donejs / done-serve

DoneJS development server
https://www.npmjs.com/package/done-serve
MIT License
7 stars 5 forks source link

A better console for --develop #22

Open matthewp opened 7 years ago

matthewp commented 7 years ago

tldr; Create an interactive console for use when developing. Instead of being a log of everything that happens on the server, it would group information by what you are more liking to care about.

This was discussed on a recent live stream (54:58) and at a contributors meeting (51:24)

The Problem

When running donejs develop in your console you will see a log of all activity that happens on the server. This could be:

And many more. It's not very attractive and looks like this:

screen shot 2017-09-22 at 9 14 20 am

The Solution

Create a new console interface that better serves the user. I would:

A proof of concept of this exists in the curses branch of done-serve. Here is a demonstration of what that looks like:

untitled

Implementation

We would like to make it possible for users to create their own UIs. We can see some exciting UIs such as:

68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f626861756d616e2d626c6f672d696d616765732f666967776865656c5f696d6167652e706e67

API

--ui <interface>

I propose adding a new flag to done-serve, --ui which allows specifying an alternative UI library.

It will load the npm module done-serve-ui-<interface> and communicate with it via an EventEmitter.

The default interface, the one that just logs everything to the console like today, could be implemented like so:

module.exports = function(events){
    events.on("log", function(msg){
        events.console.log(msg);
    });
    events.on("error", function(err){
        events.console.error(err);
    });
    events.on("live-reload", function(msg){
        events.console.error(msg);
    });
    events.on("server", function(url){
        events.console.log("done-serve starting on " + url);
    });
};

Possible UIs

Depending on what the users want, we could start building one of these UIs. Make your opinion be heard!

done-serve-ui-curses

This would be the first UI I would build, and it would be a curses interface similar to the one from the proof-of-concept. Several other ecosystems have developed similar interfaces. I think the things users care about are:

done-serve-ui-web

This would be similar to figwheel as explained above. This would require the user inject something (maybe a can-component?) into their page, which would display the information. From there the done-serve-ui-web package would communicate over websockets to display all of the information.

chasenlehara commented 7 years ago

Have more of a curses look. So not a scrollable console.

This sounds like we would lose access to previous messages. Can you explain this a little more?

matthewp commented 7 years ago

@chasenlehara

This sounds like we would lose access to previous messages. Can you explain this a little more?

It may or may not mean that. I'm not familiar enough with the curses libraries to know if, for example, the individual boxes are scrollable or not. If they are then this issue would be solved there.

Another option (which we should probably have regardless) is a --plain mode that turns off this new interface and gives you raw stdout like we have today.

justinbmeyer commented 7 years ago

Throwing this out there ... probably belongs in another issue ... but something to consider ...

Could we get this output to the client somehow?

Assuming the process is resilient enough to output this kind of stuff ... could we stream that to the client where it is much easier to style and present in a nice way?

matthewp commented 7 years ago

Yes, we should architect this in such a way as to support different presentation layers. The process that controls receiving the messages could then emit events that presenters display however they wish. Something like:

{ "type": "live-reload", "module": "main.js" }
{ "type": "error", "message": "Undefined is not a function" }
Sinjhin commented 7 years ago

I like it. My only concern is the same as Chasen's. It would be a pain if we didn't have access to a good bit of history. That seems like a deal-breaker to me.

matthewp commented 7 years ago

With blessed you can make boxes scrollable: https://github.com/chjj/blessed#options-2

matthewp commented 7 years ago

This has been started in the https://github.com/donejs/done-serve/tree/curses branch. I presented a demo in a past contributor's meeting