2.0.1 • Published 7 years ago

grunt-fetch-bindings v2.0.1

Weekly downloads
2
License
-
Repository
github
Last release
7 years ago

grunt-fetch-bindings

fetch bindings from ts files and create a json containing these values along with html-file-name and path

Getting Started

This plugin requires Grunt ~0.4.5

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-fetch-bindings --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-fetch-bindings');

The "fetch_bindings" task

Overview

In your project's Gruntfile, add a section named fetch_bindings to the data object passed into grunt.initConfig().

    grunt.initConfig({
      fetch_bindings: {
          options: {
            src: "src/",
            wildcard: "**/*.component.ts",
            dest: "dist/",
            baseURL: "ui/idp/",
            outputfile: "config/selectorList.json",
            bindname: "'cmsKey'"            
          },
          files: {
            'dest/default_options': ['src/srcfile', 'src/123'],
          }
        },
      });

Assumption - ts files

assuming the following occurence in *.component.ts files

    super.initCms({'cmsKey': {
                'savecartheading': 'Save Cart(default)',
                'deviceLabel': 'Device(default)',
                'pricingplanLabel': 'Pricing(default)',
                'protectionLabel': 'Protection(default)',
                'continueButton': 'Continue(default)',
                'editSelectionsButton': 'Edit(default)'
            }});

Package.json

{
  "name": "my-fetch-bindings-test",
  "version": "0.0.0",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-fetch-bindings": "^1.2.0"
  },
  "engines": {
    "node": ">=0.8.0"
  }
}

Options

options.src

Type: String Default value: 'src'

Directory where html files are avaiable.

options.dest

Type: String Default value: 'dist'

Directory where json file is created.

options.bindname

Type: String Default value: 'contentData'

Binding name which is to be searched through and the name of json file.

Usage Examples

Default Options

In this example, the default options are used.

    grunt.initConfig({
      fetch_bindings: {
          options: {
            src: "src/",
            wildcard: "**/*.component.ts",
            dest: "dist/",
            baseURL: "ui/idp/",
            outputfile: "config/selectorList.json",
            bindname: "'cmsKey'"            
          },
          files: {
            'dest/default_options': ['src/srcfile', 'src/123'],
          }
        },
      });

Custom Options

In this example, custom options are used.

    grunt.initConfig({
      fetch_bindings: {
          options: {
            src: "src/app/components/",
            wildcard: "**/*.component.ts",
            dest: "dist/",
            baseURL: "ui/idp/",
            outputfile: "config/selectorList.json",
            bindname: "'cmsKey'"            
          },
          files: {
            'dest/default_options': ['src/srcfile', 'src/123'],
          }
        },
      });

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

2.0.1

7 years ago

2.0.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago