inpsyde / composer-asset-compiler

Composer plugin that installs dependencies and compiles assets based on configuration.
https://inpsyde.github.io/composer-asset-compiler/
MIT License
25 stars 1 forks source link

Improve console output #11

Closed bartlangelaan closed 1 year ago

bartlangelaan commented 2 years ago

Is your feature request related to a problem? Please describe. First of all, thanks for this plugin. It really helps with the JS in Composer problem!

One of the great things about this plugin, is that it automatically does a lot automatically without any developer needing to know the ins-and-outs. However, by default it is hard to see what is happening - which is somethimes frustrating when a package is installing/building slow or if something is failing.

For example, this is how a project I'm working in looks with this plugin:

  - Installing drupal/administration_language_negotiation (1.11.0): Extracting archive
  - Installing drupal/admin_toolbar (3.0.2): Extracting archive
  - Applying patches for drupal/core
    https://www.drupal.org/files/issues/2018-07-13/1797438-145.patch (HTML5 validation is preventing form submit and not fully accessible)
    https://www.drupal.org/files/issues/2018-10-17/core-typed_config_handle_missing_config-2925297-7.patch (Fatal error on config form with translation enabled when config is missing)
    https://git.drupalcode.org/project/drupal/-/commit/ef2f0e3109e30da63341cf60779ff845b24e2e1a.patch (#3222107 - jQuery UI library order is incorrect when a large number of javascript files is loaded between two jQuery UI libraries)
    https://www.drupal.org/files/issues/2020-06-10/locale-config-langcodes.patch (#3150540 - Configuration langcode is forced to site default language)
  - Applying patches for drupal/webform
    https://www.drupal.org/files/issues/2021-11-09/70.patch (#3240249 - Aria-required on fieldset trigger accessibility fails.)
    https://git.drupalcode.org/project/webform/-/merge_requests/96.patch (#3252029 - Aria-required on fieldset trigger accessibility fails. (part 2))
    https://git.drupalcode.org/project/webform/-/commit/0056d54e445907caabfef6157c78cfd9115a40a7.patch (#3246947 - Only load jQuery UI Datepicker when needed)
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package twig/extensions is abandoned, you should avoid using it. No replacement was suggested.
Package webmozart/path-util is abandoned, you should avoid using it. Use symfony/filesystem instead.
Generating autoload files
101 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

            Inpsyde         

    Composer Assets Compiler

    starting...

    done.

Scaffolding files for drupal/core:
  - Copy [project-root]/.editorconfig from assets/scaffold/files/editorconfig
  - Copy [project-root]/.gitattributes from assets/scaffold/files/gitattributes
  - Copy [web-root]/.csslintrc from assets/scaffold/files/csslintrc
  - Copy [web-root]/.eslintignore from assets/scaffold/files/eslintignore
  - Skip [web-root]/.eslintrc.json: overridden in dvg/io_dvg
  - Copy [web-root]/.ht.router.php from assets/scaffold/files/ht.router.php
  - Copy [web-root]/.htaccess from assets/scaffold/files/htaccess
  - Copy [web-root]/example.gitignore from assets/scaffold/files/example.gitignore
  - Copy [web-root]/index.php from assets/scaffold/files/index.php
  - Copy [web-root]/INSTALL.txt from assets/scaffold/files/drupal.INSTALL.txt
  - Copy [web-root]/README.md from assets/scaffold/files/drupal.README.md
  - Copy [web-root]/robots.txt from assets/scaffold/files/robots.txt
  - Copy [web-root]/update.php from assets/scaffold/files/update.php

The Composer Assets Compiler part really looks off, compared to other plugins (composer patches & drupal-scaffold).

And if something fails, the 'done' part just changes to 'failed.' - which is not very helpful.

Describe the solution you'd like I think it would be totally possible to improve the output a bit, so it looks more consistent with other Composer plugins, and gives a bit more output without being too verbose.

I believe that it is possible for multiple installs/builds to occur concurrently, right? In that case, I can imagine that something like this would be great:

Compiling assets of composer packages using npm:
  - Starting dependency installation of bartlangelaan/package1...
  - Starting dependency installation of bartlangelaan/package2...
  - The bartlangelaan/package3 are already compiled
  - Dependencies of bartlangelaan/package2 have completed installing. Starting assets compilation...
  - Assets were succesfully compiled for bartlangelaan/package2
  - Dependencies of bartlangelaan/package1 have completed installing. Starting assets compilation...
  - Error. The compilation of bartlangelaan/package1 did not succeed.

The command was run in /home/bart/git/project/vendor/bartlangelaan/package1
The command executed was: npm run build
The command gave the following output:
[full npm output]

Output like this is not too verbose, because it just generates 3 lines per package that is being compiled, or 1 line for packages that were already compiled. At the same time, it gives a great impression of what is happening (package manager used, actions currently running, error output). It also looks more consistent with other plugins, without the Inpsyde banner.

Describe alternatives you've considered

I did think about always enabling verbose mode, which gives more output. However, I just want this plugin to show more output, I don't need full verbosity output whenever an npm build is failing.

gmazzap commented 2 years ago

Hi @bartlangelaan

The plugin, via Composer, accepts different level of verbosity.

With composer compile-assets -v you get enough infomration, very similar to what you ask.

If you want to also know the reason wht NPM/Yarn failed you've to use composer compile-assets -vvv.

In our CI we indeed always use the -v flag, which is a good indication of that being a good default.

But if the current output using the -v flag becomes the default, the -v flag output has to change, and that would affect a lot of existing CI pipelines. So I think it is something to consider for next major release.

bartlangelaan commented 2 years ago

Hey @gmazzap,

We are very happy with the auto-run option of the plugin, so it gets executed every time a composer install happens. To see more output however, the whole composer install command needs the -v flag, which is way too verbose for everyting happening in Composer.

Maybe it is possible to not add any extra information when -v is added, but just also show that information without -v? It is always possible to use --quiet if you don't want any output, right?

gmazzap commented 2 years ago

I understand @bartlangelaan

One of the reason in out workflow we turned of autorun was to be able to control verbosity separately from Composer.

I'll see if I can improve the default verbosity output.

gmazzap commented 1 year ago

v3 has a much better output.