<commit_before>var fs = require('fs');
var pkg = require('./package');
var cssPrefix = require('css-prefix');

var minor_version = pkg.version.replace(/\.(\d)*$/, '');
var major_version = pkg.version.replace(/\.(\d)*\.(\d)*$/, '');
var path = require('path');

function  rename_release (v) {
  return function (d, f) {
    var dest = path.join(d, f.replace(/(\.min)?\.js$/, '-'+ v + '$1.js'));
    return dest;
  };
}

module.exports = function (grunt) {
  grunt.initConfig({
    connect: {
      test: {
        options: {
          // base: 'test',
          hostname: '*',
          base: ['.', 'example', 'example/build', 'build'],
          port: 9999
        }
      },
      example: {
        options: {
          hostname: '*',
          base: ['example', 'example/build', 'build'],
          port: 3000
        }
      },
      'example-https': {
        options: {
          base: ['example', 'example/build', 'build'],
          port:  3000,
          protocol: 'https',
          hostname: '*',
          cert: fs.readFileSync(__dirname + '/test/support/https-certs/server.crt').toString(),
          key:  fs.readFileSync(__dirname + '/test/support/https-certs/server.key').toString()
        }
      }
    },
    browserify: {
      options: {
        bundleOptions: {
          debug: true
        },

        // Convert absolute sourcemap filepaths to relative ones using mold-source-map.
        postBundleCB: function(err, src, cb) {
          if (err) { return cb(err); }
          var through = require('through');
          var stream = through().pause().queue(src).end();
          var buffer = '';

          stream.pipe(require('mold-source-map').transformSourcesRelativeTo(__dirname)).pipe(through(function(chunk) {
            buffer += chunk.toString();
          }, function() {
            cb(err, buffer);
          }));
          stream.resume();
        }

      },
      debug: {
        files: {
          'build/auth0-lock.js': ['standalone.js']
        }
      },
    },

    // uglify: {
    //   min: {
    //     files: {
    //       'build/auth0-lock.min.js': ['build/auth0-lock.js']
    //     }
    //   }
    // },
    less: {
      dist: {
        options: {
          paths: ['lib/css'],
        },
        files: {
          'lib/css/main.css': 'lib/css/main.less'
        }
      },
      example: {
        files: {
          'example/build/index.css': 'example/index.less'
        }
      }
    },
    autoprefixer: {
      options: {
        browsers: ['> 1%', 'last 2 versions', 'ff 15', 'opera 12.1', 'ie 8']
      },
      main: {
        src:  'lib/css/main.css',
        dest: 'lib/css/main.css',
      },
    },
    prefix: { //this adds 'a0-' to every class and id
      css: {
        src: 'lib/css/main.css',
        dest: 'lib/css/main.css',
        prefix: 'a0-'
      }
    },
    cssmin: {
      minify: {
        options: {
          keepSpecialComments: 0
        },
        files: {
          'lib/css/main.min.css': ['lib/css/main.css']
        }
      }
    },
    copy: {
      example: {
        files: {
          'example/auth0-lock.min.js': 'build/auth0-lock.min.js',
          'example/auth0-lock.js':     'build/auth0-lock.js'
        }
      },
      release: {
        files: [
          { expand: true, flatten: true, src: 'build/*', dest: 'release/', rename: rename_release(pkg.version) },
          { expand: true, flatten: true, src: 'build/*', dest: 'release/', rename: rename_release(minor_version) },
          { expand: true, flatten: true, src: 'build/*', dest: 'release/', rename: rename_release(major_version) }
        ]
      }
    },
    exec: {
      'uglify': {
        cmd: 'node_modules/.bin/uglifyjs build/auth0-lock.js  -b beautify=false,ascii_only=true > build/auth0-lock.min.js',
        stdout: true,
        stderr: true
      },
      'test-integration': {
        cmd: 'node_modules/.bin/zuul -- test/*.js',
        stdout: true,
        stderr: true
      },
      'test-phantom': {
        cmd: 'node_modules/.bin/zuul --ui mocha-bdd --phantom 9999 -- test/*.js',
        stdout: true,
        stderr: true
      }
    },
    clean: {
      css: ['lib/css/main.css', 'lib/css/main.min.css'],
      js: ['release/', 'build/', 'example/auth0-lock.js']
    },
    watch: {
      js: {
        files: ['node_modules',
                'standalone.js',
                'index.js',
                'lib/**/*.js',
                'lib/**/*.ejs',
                'i18n/*'],
        tasks: ['js'],
        options: {
          livereload: true
        },
      },
      css: {
        files: [
          'lib/**/*.less'
        ],
        tasks: ['build'],
        options: {
          livereload: true
        },
      },
      example: {
        files: ['example/*'],
        tasks: ['less:example'],
        options: {
          livereload: true
        },
      }
    },
    s3: {
      options: {
        key:    process.env.S3_KEY,<commit_msg>Improving Lock watch mode.<commit_after>var fs = require('fs');
var pkg = require('./package');
var cssPrefix = require('css-prefix');

var minor_version = pkg.version.replace(/\.(\d)*$/, '');
var major_version = pkg.version.replace(/\.(\d)*\.(\d)*$/, '');
var path = require('path');

function  rename_release (v) {
  return function (d, f) {
    var dest = path.join(d, f.replace(/(\.min)?\.js$/, '-'+ v + '$1.js'));
    return dest;
  };
}

module.exports = function (grunt) {
  grunt.initConfig({
    connect: {
      test: {
        options: {
          // base: 'test',
          hostname: '*',
          base: ['.', 'example', 'example/build', 'build'],
          port: 9999
        }
      },
      example: {
        options: {
          hostname: '*',
          base: ['example', 'example/build', 'build'],
          port: 3000
        }
      },
      'example-https': {
        options: {
          base: ['example', 'example/build', 'build'],
          port:  3000,
          protocol: 'https',
          hostname: '*',
          cert: fs.readFileSync(__dirname + '/test/support/https-certs/server.crt').toString(),
          key:  fs.readFileSync(__dirname + '/test/support/https-certs/server.key').toString()
        }
      }
    },
    browserify: {
      options: {
        bundleOptions: {
          debug: true
        },
        watch: true,

        // Convert absolute sourcemap filepaths to relative ones using mold-source-map.
        postBundleCB: function(err, src, cb) {
          if (err) { return cb(err); }
          var through = require('through');
          var stream = through().pause().queue(src).end();
          var buffer = '';

          stream.pipe(require('mold-source-map').transformSourcesRelativeTo(__dirname)).pipe(through(function(chunk) {
            buffer += chunk.toString();
          }, function() {
            cb(err, buffer);
          }));
          stream.resume();
        }

      },
      debug: {
        files: {
          'build/auth0-lock.js': ['standalone.js']
        }
      },
    },

    // uglify: {
    //   min: {
    //     files: {
    //       'build/auth0-lock.min.js': ['build/auth0-lock.js']
    //     }
    //   }
    // },
    less: {
      dist: {
        options: {
          paths: ['lib/css'],
        },
        files: {
          'lib/css/main.css': 'lib/css/main.less'
        }
      },
      example: {
        files: {
          'example/build/index.css': 'example/index.less'
        }
      }
    },
    autoprefixer: {
      options: {
        browsers: ['> 1%', 'last 2 versions', 'ff 15', 'opera 12.1', 'ie 8']
      },
      main: {
        src:  'lib/css/main.css',
        dest: 'lib/css/main.css',
      },
    },
    prefix: { //this adds 'a0-' to every class and id
      css: {
        src: 'lib/css/main.css',
        dest: 'lib/css/main.css',
        prefix: 'a0-'
      }
    },
    cssmin: {
      minify: {
        options: {
          keepSpecialComments: 0
        },
        files: {
          'lib/css/main.min.css': ['lib/css/main.css']
        }
      }
    },
    copy: {
      example: {
        files: {
          'example/auth0-lock.min.js': 'build/auth0-lock.min.js',
          'example/auth0-lock.js':     'build/auth0-lock.js'
        }
      },
      release: {
        files: [
          { expand: true, flatten: true, src: 'build/*', dest: 'release/', rename: rename_release(pkg.version) },
          { expand: true, flatten: true, src: 'build/*', dest: 'release/', rename: rename_release(minor_version) },
          { expand: true, flatten: true, src: 'build/*', dest: 'release/', rename: rename_release(major_version) }
        ]
      }
    },
    exec: {
      'uglify': {
        cmd: 'node_modules/.bin/uglifyjs build/auth0-lock.js  -b beautify=false,ascii_only=true > build/auth0-lock.min.js',
        stdout: true,
        stderr: true
      },
      'test-integration': {
        cmd: 'node_modules/.bin/zuul -- test/*.js',
        stdout: true,
        stderr: true
      },
      'test-phantom': {
        cmd: 'node_modules/.bin/zuul --ui mocha-bdd --phantom 9999 -- test/*.js',
        stdout: true,
        stderr: true
      }
    },
    clean: {
      css: ['lib/css/main.css', 'lib/css/main.min.css'],
      js: ['release/', 'build/', 'example/auth0-lock.js']
    },
    watch: {
      js: {
        files: ['build/auth0-lock.js'],
        tasks: [],
        options: {
          livereload: true
        },
      },
      css: {
        files: [
          'lib/**/*.less'
        ],
        tasks: ['build'],
        options: {
          livereload: true
        },
      },
      example: {
        files: ['example/*'],
        tasks: ['less:example'],
        options: {
          livereload: true
        },
      }
    },
    s3: {
      options: {
        key:    process.env.S3_KEY,
{'fraction_non_alphanumeric': 0.17987524286736886, 'fraction_numerical': 0.008487575416709275, 'mean_word_length': 1.5154320987654322, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5232621', 'n_tokens_mistral': 3255, 'n_tokens_neox': 3144, 'n_words': 574}