grunt icon indicating copy to clipboard operation
grunt copied to clipboard

public vs private tasks

Open cowboy opened this issue 11 years ago • 37 comments

Right now, all tasks are "public" meaning that all tasks can be run on the cli. It might be helpful on projects that have finely-crafted alias tasks to be able to make tasks "private" to hide them from the --help screen and prevent them from being run on the cli (or via lib)

cowboy avatar Mar 28 '13 16:03 cowboy

It sounds like a fine idea, but since people usually need documentation to know what options or arguments a task can take, I doubt anyone will be running a task that they happen upon in the help screen if it wasn't documented somewhere else. But I could see it reducing clutter in the help output.

adamstallard avatar Mar 31 '13 05:03 adamstallard

This is very usefull if you programmatically generate bulk tasks aliasses and targets or have destructive build chain sub targets. Like a clean task target that wipes all changes, it may not be triggerd from a broader grunt clean. Also in complex gruntfile the real config tasks mean nothing on their own but are just actions to refer in an alias and should be hidden for user.

Bartvds avatar Mar 31 '13 14:03 Bartvds

Just came looking for this! :)

hemanth avatar Jul 11 '13 02:07 hemanth

This would be very helpful for task aliases (test in place of qunit with our own help message) and subtasks (test-report calls qunit_junit followed by qunit, so I'd like to hide the qunit ones in favor of test and test-report).

dharkness avatar Jul 19 '13 21:07 dharkness

+1 :)

mpaulucci avatar Aug 30 '13 13:08 mpaulucci

Hell yeah!

kud avatar Sep 10 '13 12:09 kud

Just submitted https://github.com/gruntjs/grunt/pull/930 for review. The essence is simple if the task description is explicitly set to undefined then it would not show up in the grunt --help output.

opichals avatar Oct 04 '13 14:10 opichals

+1

rweng avatar Oct 31 '13 11:10 rweng

+1

I like @opichals approach. And IMO people don't need documentation anymore (in most cases) if they are only presented with those tasks that are considered to be used by them. At the moment I include private at the beginning of each "private" tasks description. OK, but the help screen gets messy which it is not supposed to be.

asperling avatar Nov 07 '13 15:11 asperling

Any progress on this one? I like the idea of prefixing tasks with an underscore to make them not show up on --help.

codepunkt avatar Dec 08 '13 22:12 codepunkt

Related to #910? Check my PR please #1030

itayadler avatar Jan 19 '14 13:01 itayadler

If tasks were private by default, we could override such with a new optional argument in grunt.registerTask:

grunt.registerTask("name", "description", {public:true}, function(){});

While this changes previous behaviour, it would prevent us from having to hide require()'d tasks.

stevenvachon avatar Jan 29 '14 19:01 stevenvachon

Any progress?

kirill-konshin avatar Jun 20 '14 20:06 kirill-konshin

and now? :))

michahell avatar Sep 24 '14 22:09 michahell

Some IDEs already integrate with grunt and display a runable list of actions so some poor Joe with a Jetbrains IDE can compile and revert and shred all his work because of those wacky tasks we sometimes write and his curiosity he couldn't overcome. It's not really fictional..

So what's the problem with these two options? a) Tasks' description can either be a string or object b) 3rd optional object argument

In both cases the argument public: false or private: true will be available to set in ojbect.

rafi avatar Sep 30 '14 16:09 rafi

+1

monolithed avatar Nov 11 '14 22:11 monolithed

+1

kiyanwang avatar Nov 20 '14 10:11 kiyanwang

+1

dotherightthing avatar Dec 02 '14 01:12 dotherightthing

+1

wdamien avatar Dec 17 '14 18:12 wdamien

+1

sebastianderossi avatar Dec 17 '14 18:12 sebastianderossi

For those who want to hide certain tasks included via registerNpmTasks and also other internal tasks, have a look over at for example vibejs-dynclass.

There, I am late binding the tasks that I do not want the user to see. Perhaps this could be a viable solution until grunt provides a similar feature of its own?

Note that the Gruntfile is still not finalized and needs additional work, however, late binding the external tasks and some internal tasks already works.

silkentrance avatar Dec 17 '14 20:12 silkentrance

+1

vavd avatar Jan 07 '15 21:01 vavd

+1

silkimen avatar Jan 19 '15 15:01 silkimen

+1

katcipis avatar Jan 27 '15 13:01 katcipis

+1

consense avatar Feb 02 '15 14:02 consense

+1

jamesgaunt avatar Feb 03 '15 20:02 jamesgaunt

@rafi's comments about the IDEs are spot on; GUIs are now being built around grunt, so the need clean up the available tasks to the user is growing. I think the best approach to addressing this would be an option flag.

Aside from GUI considerations, some of our development teams include offshore devs, reducing the exposed tasks from the grunt CLI will help mitigate problems.

theaccordance avatar Feb 13 '15 17:02 theaccordance

How about adding the following methods

lateBindNpmTasks which would load tasks prior to that a publicly exposed task, via registerTask or loadNpmTasks is invoked.

and

lateBindTask for internal tasks that would also be made available prior to that a publicly exposed task is invoked.

and

lateBindTasks for internal tasks...

Of course, other API methods such as renameTask would have to be changed as well, e.g. post pone unresolvable renames until all late bound tasks have been loaded.

The change should be minimal and would not affect any existing plugins nor gruntfiles.

silkentrance avatar Feb 14 '15 17:02 silkentrance

@cowboy please have a look at my proposal towards late binding tasks using a suite of alternate API calls. Please note that renaming tasks is not possible with late bound tasks.

silkentrance avatar Feb 21 '15 18:02 silkentrance

+1

lzilioli avatar Feb 24 '15 17:02 lzilioli