text: /*
   * line-chart-generator
   * https://github.com/lets-fiware/line-chart-generator-operator
   *
   * Copyright (c) 2019 Kazuhito Suda
   * Licensed under the Apache2 license.
   */
  
  var ConfigParser = require('wirecloud-config-parser');
  var parser = new ConfigParser('src/config.xml');
  
  module.exports = function (grunt) {
  
      'use strict';
  
      grunt.initConfig({
  
          metadata: parser.getData(),
  
          eslint: {
              operator: {
                  src: 'src/js/**/*.js',
              },
              grunt: {
                  options: {
                      configFile: '.eslintrc-node'
                  },
                  src: 'Gruntfile.js',
              },
              test: {
                  options: {
                      configFile: '.eslintrc-jasmine'
                  },
                  src: ['src/test/**/*.js', '!src/test/fixtures/']
              }
          },
  
          copy: {
              main: {
                  files: [
                      {expand: true, cwd: 'src/js', src: '*', dest: 'build/src/js'}
                  ]
              }
          },
  
          coveralls: {
              library: {
                  src: 'build/coverage/lcov/lcov.info',
              }
          },
  
          strip_code: {
              test_code: {
                  src: ['build/src/js/**/*.js']
              }
          },
  
          compress: {
              operator: {
                  options: {
                      mode: 'zip',
                      archive: 'dist/<%= metadata.vendor %>_<%= metadata.name %>_<%= metadata.version %>.wgt'
                  },
                  files: [
                      {
                          expand: true,
                          cwd: 'src',
                          src: [
                              'DESCRIPTION.md',
                              'css/**/*',
                              'doc/**/*',
                              'images/**/*',
                              'config.xml'
                          ]
                      },
                      {
                          expand: true,
                          cwd: 'build/lib',
                          src: [
                              'lib/**/*'
                          ]
                      },
                      {
                          expand: true,
                          cwd: 'build/src',
                          src: [
                              'js/**/*'
                          ]
                      },
                      {
                          expand: true,
                          cwd: '.',
                          src: [
                              'LICENSE'
                          ]
                      }
                  ]
              }
          },
  
          clean: {
              build: {
                  src: ['build']
              },
              temp: {
                  src: ['build/src']
              }
          },
  
          karma: {
              options: {
                  customLaunchers: {
                      ChromeNoSandbox: {
                          base: "Chrome",
                          flags: ['--no-sandbox']
                      }
                  },
                  files: [
                      'node_modules/mock-applicationmashup/dist/MockMP.js',
                      'src/js/*.js',
                      'tests/js/*Spec.js'
                  ],
                  frameworks: ['jasmine'],
                  reporters: ['progress', 'coverage'],
                  browsers: ['Chrome', 'Firefox'],
                  singleRun: true
              },
              operator: {
                  options: {
                      coverageReporter: {
                          type: 'html',
                          dir: 'build/coverage'
                      },
                      preprocessors: {
                          'src/js/*.js': ['coverage'],
                      }
                  }
              },
              operatorci: {
                  options: {
                      junitReporter: {
                          "outputDir": 'build/test-reports'
                      },
                      reporters: ['junit', 'coverage'],
                      browsers: ['ChromeNoSandbox', 'Firefox'],
                      coverageReporter: {
                          reporters: [
                              {type: 'cobertura', dir: 'build/coverage', subdir: 'xml'},
                              {type: 'lcov', dir: 'build/coverage', subdir: 'lcov'},
                          ]
                      },
                      preprocessors: {
                          "src/js/*.js": ['coverage'],
                      }
                  }
              }
          },
  
          wirecloud: {
              options: {
                  overwrite: false
              },
              publish: {
                  file: 'dist/<%= metadata.vendor %>_<%= metadata.name %>_<%= metadata.version %>.wgt'
              }
          }
  
      });
  
      grunt.loadNpmTasks('grunt-wirecloud');
      grunt.loadNpmTasks('grunt-karma'); // when test?
      grunt.loadNpmTasks('gruntify-eslint');
      grunt.loadNpmTasks('grunt-contrib-compress');
      grunt.loadNpmTasks('grunt-contrib-copy');
      grunt.loadNpmTasks('grunt-contrib-clean');
      grunt.loadNpmTasks('grunt-coveralls');
      grunt.loadNpmTasks('grunt-strip-code');
      grunt.loadNpmTasks('grunt-text-replace');
  
      grunt.registerTask('test', [
          'eslint',
          // 'karma:operator'
      ]);
  
      grunt.registerTask('ci', [
          'eslint',
          // 'karma:operatorci',
          'coveralls'
      ]);
  
      grunt.registerTask('build', [
          'clean:temp',
          'copy:main',
          'strip_code',
          'compress:operator'
      ]);
  
      grunt.registerTask('default', [
          'test',
          'build'
      ]);
  
      grunt.registerTask('publish', [
          'default',
          'wirecloud'
      ]);
  
  };
  