grunt-redact
What's this?
Pre-runtime feature toggle support for static applications where toggle-related code can't be delivered to the client.
Do you need pre-runtime feature toggle support for your client-side JavaScript app? Then you've come to the right place.
Why?
In most scenarios client-side feature toggling is enough and you can get away with simple toggling mechanisms in your client-side app. However, in scenarios where clients simply cannot have any access to half-baked or hidden features, you need something that will remove all traces that there was ever any feature toggle in your codebase.
Getting Started
This plugin requires Grunt ~0.4.2
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-redact --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "redact" task
Overview
In your project's Gruntfile, add a section named redact
to the data object passed into grunt.initConfig()
.
grunt;
The task will redact JavaScript (**/*.js) and HTML (**/*.html) files inside the directory specified on workingDirectory
.
HTML files
Facebook login goes hereSorry, we do not support Facebook login yet
JavaScript files
if featurefacebookLogin console;
Options
workingDirectory
Type: String
Location of files to be redacted. For example, it can be the path where you run your application when using grunt server
.
Note: this should not be your source code folder, since files are edited in place—it should be a target folder from where you run your app, where file contents are disposable (and most likely ignored by your source control tool.)
toggleStatesFile
Type: String
Location of the JSON file that contains your feature toggles and their respective states.
The file should contain a simple JavaScript object with the feature names and their respective states. For example:
"googleLogin": true "facebookLogin": false
Usage Examples
On your Gruntfile.js:
grunt;