<commit_before>#
# Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
# Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
#

module.exports = (grunt) ->
  jasmineRequireTemplate = require 'grunt-template-jasmine-requirejs'

  jasmineSpecRunner = 'spec-runner.html'

  sourcePath = 'target/classes/static/js/find/**/*.js'

  browserTestRequireConfig = [
    'target/classes/static/js/require-config.js'
    'src/test/js/test-require-config.js'
  ]

  testRequireConfig = browserTestRequireConfig.concat([
    'src/test/js/es5-test-require-config.js'
  ])

  specs = 'target/es5-jasmine-test-specs/spec/**/*.js'
  browserSpecs = 'src/test/js/spec/**/*.js'
  serverPort = 8000

  testWatchFiles = [
    'target/classes/static/**/*.js'
    'src/test/**/*.js'
  ]

  grunt.initConfig
    pkg: grunt.file.readJSON 'package.json'
    babel:
      options:
        plugins: ['transform-es2015-block-scoping']
      transform:
        files: [{
          expand: true
          cwd: 'target/classes/static/js'
          src: ['find/**/*.js']
          dest: 'target/es5-jasmine-test'
          ext: '.js'
        }, {
          expand: true
          cwd: 'src/test/js'
          src: ['**/*.js']
          dest: 'target/es5-jasmine-test-specs'
          ext: '.js'
        }]
    clean: [
      jasmineSpecRunner
      'bin'
      '.grunt'
    ]
    connect:
      server:
        options:
          port: serverPort
          useAvailablePort: true
    jasmine:
      test:
        src: sourcePath
        options:
          keepRunner: false
          outfile: jasmineSpecRunner
          specs: specs
          template: jasmineRequireTemplate
          templateOptions:
            requireConfigFile: testRequireConfig
          junit:
            path: "target/jasmine-tests"
            consolidate: true
      'browser-test':
        src: sourcePath
        options:
          keepRunner: false
          outfile: jasmineSpecRunner
          specs: browserSpecs
          template: jasmineRequireTemplate
          templateOptions:
            requireConfigFile: browserTestRequireConfig
    watch:
      options:
        interval: 5000
      buildBrowserTest:
        files: testWatchFiles
        tasks: ['jasmine:browser-test:build']
      test:
        files: testWatchFiles
        tasks: ['test']
      copyResources:
        files: [
          '../core/src/main/public/static/**/*'
          '../core/src/main/resources/less/**/*.less'
          'src/main/public/static/**/*'
        ]
        spawn: false
        tasks: ['sync:devResources']
      fieldtext:
        files: [
          '../core/src/main/public/static/bower_components/hp-autonomy-fieldtext-js/src/js/field-text.pegjs'
        ],
        tasks: ['peg:fieldtext']
    sync:
      devResources:
        files: [
          {
            cwd: '../core/src/main/resources/less'
            src: '**/*'
            dest: '../core/target/classes/less'
          }
          {
            cwd: '../core/src/main/public/static'
            src: '**/*'
            dest: 'target/classes/static'
          }
          {
            cwd: 'src/main/public/static/'
            src: '**/*'
            dest: 'target/classes/static'
          }
        ]
        verbose: true
    peg:
      fieldtext:
        src: '../core/src/main/public/static/bower_components/hp-autonomy-fieldtext-js/src/js/field-text.pegjs'
        dest: 'target/classes/static/js/pegjs/fieldtext/parser.js'
        options:
          format: 'amd'
          trackLineAndColumn: true
    requirejs:
      options:
        appDir: 'target/webapp'
        baseUrl: 'static/js'
        dir: 'target/classes'
        keepBuildDir: true
        mainConfigFile: 'target/webapp/static/js/require-config.js'
        optimize: 'none'
      public:
        options:
          name: 'public',
          include: [
            'require-config'
            'find/idol/app/idol-app'
          ]
      config:
        options:
          name: 'config',
          include: [
            'require-config',
            'find/config/config-app'
          ]
      login:
        options:
          name: 'login',
          include: [
            'require-config',
            'login-page/js/login',
            'i18n!find/nls/bundle'
          ]
    uglify:
      options:
        compress: true
        mangle: true
      js:
        files: [{
          expand: true
          cwd: 'target/classes/static/js'
          src: '**/*.js'
          dest: 'target/classes/static/js'
        }]<commit_msg>(FIND-1500, CCUK-2403) Create source maps on minified production Find. Only minify the concatenated require.js files (since most of the Find code is served from them instead of the plain files); which should speed up the build.<commit_after>#
# Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
# Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
#

module.exports = (grunt) ->
  jasmineRequireTemplate = require 'grunt-template-jasmine-requirejs'

  jasmineSpecRunner = 'spec-runner.html'

  sourcePath = 'target/classes/static/js/find/**/*.js'

  browserTestRequireConfig = [
    'target/classes/static/js/require-config.js'
    'src/test/js/test-require-config.js'
  ]

  testRequireConfig = browserTestRequireConfig.concat([
    'src/test/js/es5-test-require-config.js'
  ])

  specs = 'target/es5-jasmine-test-specs/spec/**/*.js'
  browserSpecs = 'src/test/js/spec/**/*.js'
  serverPort = 8000

  testWatchFiles = [
    'target/classes/static/**/*.js'
    'src/test/**/*.js'
  ]

  grunt.initConfig
    pkg: grunt.file.readJSON 'package.json'
    babel:
      options:
        plugins: ['transform-es2015-block-scoping']
      transform:
        files: [{
          expand: true
          cwd: 'target/classes/static/js'
          src: ['find/**/*.js']
          dest: 'target/es5-jasmine-test'
          ext: '.js'
        }, {
          expand: true
          cwd: 'src/test/js'
          src: ['**/*.js']
          dest: 'target/es5-jasmine-test-specs'
          ext: '.js'
        }]
    clean: [
      jasmineSpecRunner
      'bin'
      '.grunt'
    ]
    connect:
      server:
        options:
          port: serverPort
          useAvailablePort: true
    jasmine:
      test:
        src: sourcePath
        options:
          keepRunner: false
          outfile: jasmineSpecRunner
          specs: specs
          template: jasmineRequireTemplate
          templateOptions:
            requireConfigFile: testRequireConfig
          junit:
            path: "target/jasmine-tests"
            consolidate: true
      'browser-test':
        src: sourcePath
        options:
          keepRunner: false
          outfile: jasmineSpecRunner
          specs: browserSpecs
          template: jasmineRequireTemplate
          templateOptions:
            requireConfigFile: browserTestRequireConfig
    watch:
      options:
        interval: 5000
      buildBrowserTest:
        files: testWatchFiles
        tasks: ['jasmine:browser-test:build']
      test:
        files: testWatchFiles
        tasks: ['test']
      copyResources:
        files: [
          '../core/src/main/public/static/**/*'
          '../core/src/main/resources/less/**/*.less'
          'src/main/public/static/**/*'
        ]
        spawn: false
        tasks: ['sync:devResources']
      fieldtext:
        files: [
          '../core/src/main/public/static/bower_components/hp-autonomy-fieldtext-js/src/js/field-text.pegjs'
        ],
        tasks: ['peg:fieldtext']
    sync:
      devResources:
        files: [
          {
            cwd: '../core/src/main/resources/less'
            src: '**/*'
            dest: '../core/target/classes/less'
          }
          {
            cwd: '../core/src/main/public/static'
            src: '**/*'
            dest: 'target/classes/static'
          }
          {
            cwd: 'src/main/public/static/'
            src: '**/*'
            dest: 'target/classes/static'
          }
        ]
        verbose: true
    peg:
      fieldtext:
        src: '../core/src/main/public/static/bower_components/hp-autonomy-fieldtext-js/src/js/field-text.pegjs'
        dest: 'target/classes/static/js/pegjs/fieldtext/parser.js'
        options:
          format: 'amd'
          trackLineAndColumn: true
    requirejs:
      options:
        appDir: 'target/webapp'
        baseUrl: 'static/js'
        dir: 'target/classes'
        keepBuildDir: true
        mainConfigFile: 'target/webapp/static/js/require-config.js'
        optimize: 'none'
        generateSourceMaps: true
      public:
        options:
          name: 'public',
          include: [
            'require-config'
            'find/idol/app/idol-app'
          ]
      config:
        options:
          name: 'config',
          include: [
            'require-config',
            'find/config/config-app'
          ]
      login:
        options:
          name: 'login',
          include: [
            'require-config',
            'login-page/js/login',
            'i18n!find/nls/bundle'
          ]
    uglify:
      options:
        compress: true
        mangle: true
        sourceMap: true
        sourceMapName: (file) -> file + '.map'
        sourceMapIn: (file) -> file + '.map'
      js:
        files: [{
          expand: true
          cwd: 'target/classes/static/js'
          src: ['public.js', 'config.js', 'login.js']
          dest: 'target/classes/static/js'
        }]
{'fraction_non_alphanumeric': 0.12643558154103154, 'fraction_numerical': 0.005429108373355606, 'mean_word_length': 1.6344884488448845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6932954', 'n_tokens_mistral': 2937, 'n_tokens_neox': 2851, 'n_words': 527}