zaaack / foy

A simple, light-weight, type-friendly and modern task runner for general purpose.
http://zaaack.github.io/foy
MIT License
268 stars 15 forks source link

FEATURE: Task progress for tasks run from within a parent task #5

Closed dominicporteous closed 5 years ago

dominicporteous commented 5 years ago

Tracking in #6


Just wondering if you had an opinion on this, my previous PR (#4) added a flag to hide 'sub tasks' when called from within a parent context.

I get that the function of this message in the console is to indicate that a particular task has been called from the parent - I thought that perhaps a better way of displaying this would be for each subtask to have a spinner indicating the progress just as the top-level tasks do? The bottom most task/spinner would always be the top most task, with the children indented depending on the sub task level

I think this would be better for seeing progress of the subtasks and the hierarchy of tasks when there are multiple dependancies and subtasks.

Any thoughts? I've given a quick illustration below


Task: package.plugins - Depends on: package.docker.plugins
Task: package.docker.plugins - Depends on: package.docker.base
Task: package.docker.base - Depends on package.binaries
Task: package.binaries - Depends on build.core - Calls package.binaries.client, package.binaries.client
Task: build.core - Depends on build.core.pre - Calls build.core.client, build.core.main

Current Behaviour:

✔ build.core.pre
⠋ build.core Task: build.core.client
Task: build.core.main
✔ build.core
⠋ package.binaries Task: package.binaries.client
Task: package.binaries.main
✔ package.binaries
✔ package.docker.base
✔ package.docker.plugins
✔ package.plugins

Desired Behaviour:

    ✔ build.core
        ✔ build.core.pre
        ✔ build.core.client
        ✔ build.core.main
    ✔ package.binaries
        ✔ package.binaries.client
        ✔ package.binaries.main
    ✔ package.docker.plugins
        ✔ package.docker.base
✔ package.plugins

zaaack commented 5 years ago

@dominicporteous Actually, when I implement the loading part of Foy, I thought of this kind of interface, too. Then quickly I give up it because of the trouble. But since you proposed, I think we can give a try. Here are some ideas that I can give:

  1. We don't need to wait for Ora to implement indent, I think we can extend Ora class and override frames options and stopAndPersist to append spaces between loading and state via options.

  2. To show the dependency graph, perhaps we need to refactor a resolveDependencyTree method, so we can keep the code dry and clean.

  3. I know loading is great, but if we running Foy in a ci/cd server, I think disabling loading makes more sense. Perhaps we can print a no state dependency graph on the beginning, and then log the normal logs.

  4. The loading spinner might conflict with normal logs, after looking into Ora's code, I find Ora would write to stderr, perhaps we can provide an option to redirect an option to redirect the stdout to a log file. e.g.

var logStream = fs.createWriteStream('./foy.log')
process.stdout.write = logStream.write.bind(access)

But since Ora would write to stderr, we can simply disable normal logs via foy build > foy.log. Therefore, I'm not sure this option is useful.

This might be a log of work. If you don't have enough time, I think I can implement this these days by myself. Thanks for your proposal and previous work.

zaaack commented 5 years ago

@dominicporteous The dependency graph that you proposed is implemented in https://github.com/zaaack/foy/commit/f98c2d390c2dab9ad125ee1fb5370491b7cc3518 and published at v0.1.9, I'll close the issue for now, if you still have any problems, feel free to reopen it or create a new one, thanks!