clink-completions icon indicating copy to clipboard operation
clink-completions copied to clipboard

Adding suppport for gulpjs

Open piotr-cz opened this issue 8 years ago • 8 comments

See gulpjs.com.

When there is a local gupfile in current working directory, command prompt has a prefix [gulp] and completions shows up available tasks.

Otherwise there completions show --version and --gulpfile command. When the later one is used with valid remote gulpfile, completions again show its available tasks.

By mistake I created feature branch based on my master branch already containing a #44 bugfix which is not merged yet here. If it's a problem, let me know.

piotr-cz avatar Feb 03 '16 21:02 piotr-cz

@piotr-cz, it's ok, and i can just cherry-pick https://github.com/piotr-cz/clink-completions/commit/aaafc87af66fe800f9e5a11a952d7be99ff1f712 to master

I'm testing it now and i see there is some problems with performance. I have a gulpfile with over 20 tasks and double TAB takes ~10 seconds to display available tasks. I need to take a look more thoroughly into it before i'll merge it

vladimir-kotikov avatar Feb 05 '16 07:02 vladimir-kotikov

It takes about ~2s on my machine for 10 tasks. Each time when pressing tab key the interface is frozen.

Please try to execute tasks manually using gulp --tasks-simple and compare difference in performance - for me this takes similar amount of time as when using completion and IMHO the performance issue is in Gulp.

You may try using the --no-color and --silent flags, maybe these could improve the speed.

The node process is being executed 2x - the first time just to find out that there is more than one option so interface doesn't show anything output at all. Probably this could be worked out by returning empty table on first run or caching the results for second run . But both solutions are non-standard.

I'm using gulp v3.9, apparenty it's possible to install v4 brach releases using npm install gulpjs/gulp#4.0 -g. Maybe performance has improved there.

I've also just noticed that gulpjs has some completions available, including PowerShell. I'll check if some things may be ported to clink completion.

piotr-cz avatar Feb 05 '16 09:02 piotr-cz

Another option would be to manually look up gulpfile.js for gulp.task('taskName', strings

piotr-cz avatar Feb 05 '16 09:02 piotr-cz

Ah, I didn't notice that you are running gulp to get tasks list. This is indeed a thing, that causes these performance gaps. I'd recommend to look at parsing gulpfile, as you suggested.

An example of this approach is npm run completions here: https://github.com/vladimir-kotikov/clink-completions/blob/master/npm.lua#L62-L96

vladimir-kotikov avatar Feb 05 '16 11:02 vladimir-kotikov

I'm not sure that running a regex on javascript file is good idea. I mean, what if for example the gulp.task call will be commented?

Other gulpjs completion implemetations use same method to retrieve tasks by calling --tasks-simple

piotr-cz avatar Feb 05 '16 17:02 piotr-cz

Yep, also Powershell stuff uses caching, based on gulpfile's shasum, which, i guess, improves performance dramatically, as they don't need to run gulp each time to get tasks list.

vladimir-kotikov avatar Feb 09 '16 19:02 vladimir-kotikov

Added support for gulpfile.babel.js

piotr-cz avatar Mar 31 '17 10:03 piotr-cz

Codecov Report

Merging #45 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #45   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          56     56           
=====================================
  Hits           56     56

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 34d3c0c...02f6677. Read the comment docs.

codecov-io avatar Mar 31 '17 10:03 codecov-io

I'll look at this sometime in the next couple of weeks.

chrisant996 avatar Aug 15 '22 14:08 chrisant996

I'm willing to help make changes to this script, in order to be able to include it.

I have some questions and suggestions after reviewing the script:

Re: prompt --

Forcibly adding to the prompt isn't compatible with many custom prompts. That will need to at least be configurable, and maybe off by default.

Re: parsers --

The script tells Clink to merge 3 parsers with different syntaxes. It seems that probably isn't going to have quite the desired outcome. It's probably better to write a single parser with the desired syntax.

Newer versions of Clink have features that make it easier to use the value from the --gulpfile flag, and find it anywhere in the command line, and support multiple commands in the command line (e.g. using & to join them). See Responding to Arguments in Argmatchers.

Is there a default gulpfile that can be assumed when there's no --gulpfile flag present?

chrisant996 avatar Aug 18 '22 16:08 chrisant996

Please take over this PR. I'm not using both clink and gulp anymore.

piotr-cz avatar Aug 19 '22 08:08 piotr-cz

Ok, thanks for letting me know.

Closing this for now.

chrisant996 avatar Aug 19 '22 18:08 chrisant996