grunt icon indicating copy to clipboard operation
grunt copied to clipboard

Implement deprecate API and deprecate APIs

Open shama opened this issue 7 years ago • 2 comments

Ref: https://github.com/gruntjs/rfcs/pull/1

This implements an internal deprecations API that displays a warning in the console if one of the deprecated APIs are used.

To hide deprecation warnings, use --hide-deprecations on the CLI or grunt.option('hide-deprecations', true) in your Gruntfile.

When --stack or grunt.option('stack', true) is enabled, the deprecation warnings will print stack traces out to locate the deprecated APIs.


The following APIs will be publicly deprecated:

  • All functions on grunt.util._
  • All functions on grunt.util.async
  • All functions on grunt.util.namespace
  • All functions on grunt.util.hooker
  • grunt.util.exit
  • grunt.util.toArray
  • grunt.util.repeat
  • All functions on grunt.file.glob
  • All functions on grunt.file.minimatch
  • All functions on grunt.file.findup
  • grunt.file.readYAML
  • grunt.file.readJSON
  • All functions on grunt.event

The following APIs should be considered for deprecation although there isn't simple alternatives to point people to at this time (help?):

  • grunt.util.spawn
  • grunt.util.callbackify
  • grunt.util.kindOf
  • grunt.util.pluralize
  • grunt.util.recurse

~~Internally Grunt still uses these deprecated APIs. We should address those deprecation warning internally first too.~~

All deprecations have now been fixed in this PR.


This can be released on next minor release as it is backwards compatible but only adds a new behavior. Removing the deprecated APIs will happen on the next major release.

shama avatar Feb 12 '18 02:02 shama

Overall, makes sense to me, Thanks, @shama for doing this. I do like the idea, though, of first implementing the warnings in verbose mode only, then in a subsequent minor release, in non-verbose mode, and then finally removing the exposed methods in a future major release. However, I'm not sure how much I care :)

cowboy avatar Feb 12 '18 04:02 cowboy

Code looks good, but I will need to run this locally to make sure it deprecates. I Will try to get to that soon

vladikoff avatar Feb 28 '18 05:02 vladikoff