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

tasks-json, version and help flag should imply silent #157

Closed
demurgos opened this issue Apr 6, 2018 · 7 comments
Closed

tasks-json, version and help flag should imply silent #157

demurgos opened this issue Apr 6, 2018 · 7 comments
Projects

Comments

@demurgos
Copy link
Member

demurgos commented Apr 6, 2018

The expected output of tasks-json is to emit a JSON representation of the available tasks to the standard output.
Some extra logs may be emitted, causing parse errors by consummers. For example when a gulpfile is transpiled, it emits the line [<time>] Requiring external module <transpiler> followed by the JSON output.

The workaround is to use the --silent flag to suppress the extra logs. Some tools may be missing this flag so they do not work reliably when extra logs are emitted.

Enabling the --silent flag automatically when --tasks-json is used and no log-level is configured would fix those errors and improve ergonomics.

@phated
Copy link
Member

phated commented Apr 7, 2018

I thought we did this. @sttk any ideas? @demurgos which version of gulp - the --tasks-json recently was backported to 3.x and maybe we missed the silence part?

@demurgos
Copy link
Member Author

demurgos commented Apr 7, 2018

I have this issue with both the standalone CLI (gulp-cli@2.0.1) and the one bundled with Gulp (gulp@4.0.0):

Running from bash in my project:

$ which gulp
/usr/bin/gulp
$ ls -al /usr/bin/gulp 
lrwxrwxrwx 1 root root 40 2018-04-07 22:14 /usr/bin/gulp -> ../lib/node_modules/gulp-cli/bin/gulp.js
$ gulp --version
[22:14:11] Requiring external module ts-node/register
[22:14:11] CLI version 2.0.1
[22:14:11] Local version 4.0.0
$ gulp --tasks-json
[22:14:18] Requiring external module ts-node/register
{"label":"Tasks for /data/projects/various/turbo-gulp/gulpfile.ts","nodes":[{"label":"lib:dist:publish","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"lib:clean","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:dist:copy:scripts","type":"function","nodes":[]},{"label":"lib:dist:copy:custom-typings","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"_build:scripts","type":"function","nodes":[]}]},{"label":"lib:dist:package.json","type":"function","nodes":[]}]}]},{"label":"lib:dist:publish","type":"function","nodes":[]}]}]},{"label":"lib:build:scripts","type":"task","nodes":[]},{"label":"lib:build:copy","type":"task","nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"lib:build","type":"task","nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:build:scripts","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]}]},{"label":"lib:watch","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:build:scripts","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:watch:scripts","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"<anonymous>","type":"function","nodes":[]}]}]}]}]},{"label":"lib:clean","type":"task","nodes":[]},{"label":"lib:tsconfig.json","type":"task","nodes":[]},{"label":"lib:typedoc","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"lib:tsconfig.json","type":"function","nodes":[]},{"label":"_typedoc","type":"function","nodes":[]}]}]},{"label":"lib:typedoc:deploy","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"lib:tsconfig.json","type":"function","nodes":[]},{"label":"_typedoc","type":"function","nodes":[]}]},{"label":"deployTypedocTask","type":"function","nodes":[]}]}]},{"label":"lib:dist:copy","type":"task","nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:dist:copy:scripts","type":"function","nodes":[]},{"label":"lib:dist:copy:custom-typings","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]}]},{"label":"lib:dist:package.json","type":"task","nodes":[]},{"label":"lib:dist","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"lib:clean","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:dist:copy:scripts","type":"function","nodes":[]},{"label":"lib:dist:copy:custom-typings","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"_build:scripts","type":"function","nodes":[]}]},{"label":"lib:dist:package.json","type":"function","nodes":[]}]}]}]},{"label":"test:build:scripts","type":"task","nodes":[]},{"label":"test:build:copy","type":"task","nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"test:build","type":"task","nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"test:build:scripts","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]}]},{"label":"test:watch","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"test:build:scripts","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"test:watch:scripts","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"<anonymous>","type":"function","nodes":[]}]}]}]}]},{"label":"test:clean","type":"task","nodes":[]},{"label":"test:tsconfig.json","type":"task","nodes":[]},{"label":"test:run:cjs","type":"task","nodes":[]},{"label":"test:run:esm","type":"task","nodes":[]},{"label":"test:run","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"test:run:cjs","type":"function","nodes":[]},{"label":"test:run:esm","type":"function","nodes":[]}]}]},{"label":"test:coverage","type":"task","nodes":[]},{"label":"test","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"test:clean","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"test:build:scripts","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"test:coverage","type":"function","nodes":[]}]}]},{"label":":bump-major","type":"task","nodes":[]},{"label":":bump-minor","type":"task","nodes":[]},{"label":":bump-patch","type":"task","nodes":[]},{"label":":lint","type":"task","nodes":[]},{"label":":lint:fix","type":"task","nodes":[]},{"label":":tslint.json","type":"task","nodes":[]},{"label":"all:tsconfig.json","type":"task","nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:tsconfig.json","type":"task","nodes":[]},{"label":"test:tsconfig.json","type":"task","nodes":[]}]}]},{"label":"dist","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"lib:clean","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:dist:copy:scripts","type":"function","nodes":[]},{"label":"lib:dist:copy:custom-typings","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"_build:scripts","type":"function","nodes":[]}]},{"label":"lib:dist:package.json","type":"function","nodes":[]}]}]}]},{"label":"default","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"lib:clean","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"lib:dist:copy:scripts","type":"function","nodes":[]},{"label":"lib:dist:copy:custom-typings","type":"function","nodes":[]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]},{"label":"<parallel>","type":"function","branch":true,"nodes":[{"label":"_copy","type":"function","nodes":[]}]}]},{"label":"_build:scripts","type":"function","nodes":[]}]},{"label":"lib:dist:package.json","type":"function","nodes":[]}]}]}]}]}

The linked issue (with Webstorm) uses the command:

$ /usr/bin/node /data/projects/various/turbo-gulp/node_modules/gulp/bin/gulp.js --no-color --gulpfile /data/projects/various/turbo-gulp/gulpfile.ts --tasks-json

So it uses the bin included in gulp@4 (not gulp-cli).

@phated
Copy link
Member

phated commented Apr 7, 2018

That's frightening 😉Thanks for more details.

@sttk
Copy link
Contributor

sttk commented Apr 8, 2018

@demurgos @phated About --tasks-json, this issue can be fixed by adding opts.tasksJson in this condition. I'll send a pr for this.

If it is needed to suppress requiring logs for --version and --help (and more flags?), a few more modifications are needed. (stop logging in first toConsole, and enable logging in second toConsole).

@demurgos
Copy link
Member Author

demurgos commented Apr 8, 2018

--version and --help are intended for humans so the extra logs are less problemematic, but it still would be good to only keep the relevant information. The use of the transpiler is not related to the version or help. I did not look into the code details, but from a user point of view it may be surprising that these commands load the gulpfile.

@phated phated added this to TODO in v4 Dec 7, 2018
@phated phated changed the title tasks-json flag should imply silent tasks-json, version and help flag should imply silent Mar 13, 2019
@phated phated moved this from TODO to In Progress in v4 Mar 13, 2019
@phated phated closed this as completed in a4236f2 Mar 18, 2019
@phated
Copy link
Member

phated commented Mar 18, 2019

:shipit:

@phated
Copy link
Member

phated commented Mar 26, 2019

A fix for this has been published in gulp-cli 2.1.0!

@phated phated moved this from In Progress to Done in v4 Apr 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v4
  
Done
Development

No branches or pull requests

3 participants