<commit_before>/*
 * grunt-flyway
 * https://github.com/bgaillard/grunt-flyway
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

    var ChildProcess = require('child_process'),
        Util = require('util'),
        Os = require('os'),
        Path = require('path');

    // Please see the Grunt documentation for more information regarding task
    // creation: http://gruntjs.com/creating-tasks
    grunt.registerMultiTask('flyway', 'Your task description goes here.', function() {

        // Merge task-specific and/or target-specific options with these defaults.
        var options = this.options();

        var done = this.async();

        // Path to the Flyway Command Line 'bin' directory
        var flywayBinPath = Path.resolve(__dirname, '../flyway-3.2.1/lib');

        // Windows CLASSPATH separator
        var classPathSeparator = ';';

        // Unix CLASSPATH separator
        if(Os.platform() === 'linux' || Os.platform() === 'darwin') {

            classPathSeparator = ':';

        }

        // Creates the Java CLASSPATH used to run Flyway
        var javaClasspath = flywayBinPath + '/flyway-commandline-3.2.1.jar' + classPathSeparator;
        javaClasspath = javaClasspath + flywayBinPath + '/flyway-core-3.2.1.jar';

        // Object used to configure the Flyway Commands which are available with the Grunt Flyway Plugin
        // Currently available commands are :
        // - clean      : Drops all objects in the configured schemas
        // - init       : Creates and initializes the metadata table
        // - migrate    : Migrates the database
        // - validate   : Validates the applied migrations against the ones available on the classpath
        //
        // The following commands are currently not available : 'info', 'repair'
        var availableCommands = {
            clean: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                jarDir: {}
            },
            init: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                table: {},
                jarDir: {},
                initVersion: {},
                initDescription: {}
            },
            migrate: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                table: {},
                locations: {},
                jarDir: {},
                sqlMigrationPrefix: {},
                sqlMigrationSuffix: {},
                encoding: {},
                placeholders: {
                    isObject: true
                },
                placeholderPrefix: {},
                placeholderSuffix: {},
                target: {},
                outOfOrder: {},
                validateOnMigrate: {},
                cleanOnValidationError: {},
                initOnMigrate: {},
                initVersion: {},
                initDescription: {}
            },
            validate: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                table: {},
                locations: {},
                jarDir: {},
                sqlMigrationPrefix: {},
                sqlMigrationSuffix: {},
                encoding: {},
                placeholders: {
                    isObject: true
                },
                placeholderPrefix: {},
                placeholderSuffix: {},
                target: {},
                outOfOrder: {},
                cleanOnValidationError: {}
            }
        };

        // Checks if the provided Flyway command name is valid (i.e supported by the Grunt Flyway Plugin)
        if(!availableCommands.hasOwnProperty(this.data.command)) {

            grunt.log.error(
                Util.format('Flyway does not provide any command named \'%s\' or this command is not currently supported by the Plugin !',
                    this.data.command));

            return done(false);

        }

        // Create the Console Command line used to execute the Flyway Command Line program
        var flywayCommand = 'java -cp ' + javaClasspath + ' org.flywaydb.commandline.Main ' + this.data.command;

        // Gets valid command line options associated to the Flyway Command which have been entered
        var commandOptions = availableCommands[this.data.command];
<commit_msg>Update clean,baseline,migrate and validate available commmands to version 3.2.1<commit_after>/*
 * grunt-flyway
 * https://github.com/bgaillard/grunt-flyway
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

    var ChildProcess = require('child_process'),
        Util = require('util'),
        Os = require('os'),
        Path = require('path');

    // Please see the Grunt documentation for more information regarding task
    // creation: http://gruntjs.com/creating-tasks
    grunt.registerMultiTask('flyway', 'Your task description goes here.', function() {

        // Merge task-specific and/or target-specific options with these defaults.
        var options = this.options();

        var done = this.async();

        // Path to the Flyway Command Line 'bin' directory
        var flywayBinPath = Path.resolve(__dirname, '../flyway-3.2.1/lib');

        // Windows CLASSPATH separator
        var classPathSeparator = ';';

        // Unix CLASSPATH separator
        if(Os.platform() === 'linux' || Os.platform() === 'darwin') {

            classPathSeparator = ':';

        }

        // Creates the Java CLASSPATH used to run Flyway
        var javaClasspath = flywayBinPath + '/flyway-commandline-3.2.1.jar' + classPathSeparator;
        javaClasspath = javaClasspath + flywayBinPath + '/flyway-core-3.2.1.jar';

        // Object used to configure the Flyway Commands which are available with the Grunt Flyway Plugin
        // Currently available commands are :
        // - clean      : Drops all objects in the configured schemas
        // - init       : Creates and initializes the metadata table
        // - migrate    : Migrates the database
        // - validate   : Validates the applied migrations against the ones available on the classpath
        //
        // The following commands are currently not available : 'info', 'repair'
        var availableCommands = {
            clean: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                jarDirs: {},
                callbacks: {}
            },
            baseline: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                table: {},
                jarDirs: {},
                callbacks: {},
                baselineVersion: {},
                baselineDescription: {}
            },
            migrate: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                table: {},
                locations: {},
                jarDirs: {},
                sqlMigrationPrefix: {},
                sqlMigrationSeparator: {},
                sqlMigrationSuffix: {},
                encoding: {},
                placeholders: {
                    isObject: true
                },
                placeholderPrefix: {},
                placeholderSuffix: {},
                resolvers: {},
                callbacks: {},
                target: {},
                outOfOrder: {},
                validateOnMigrate: {},
                cleanOnValidationError: {},
                baselineOnMigrate: {},
                baselineVersion: {},
                baselineDescription: {}
            },
            validate: {
                url: {
                    required: true
                },
                driver: {},
                user: {},
                password: {},
                schemas: {},
                table: {},
                locations: {},
                jarDirs: {},
                sqlMigrationPrefix: {},
                sqlMigrationSeparator: {},
                sqlMigrationSuffix: {},
                encoding: {},
                placeholderReplacement: {},
                placeholders: {
                    isObject: true
                },
                placeholderPrefix: {},
                placeholderSuffix: {},
                resolvers: {},
                callbacks: {},
                target: {},
                outOfOrder: {},
                cleanOnValidationError: {}
            }
        };

        // Checks if the provided Flyway command name is valid (i.e supported by the Grunt Flyway Plugin)
        if(!availableCommands.hasOwnProperty(this.data.command)) {

            grunt.log.error(
                Util.format('Flyway does not provide any command named \'%s\' or this command is not currently supported by the Plugin !',
                    this.data.command));

            return done(false);

        }

        // Create the Console Command line used to execute the Flyway Command Line program
        var flywayCommand = 'java -cp ' + javaClasspath + ' org.flywaydb.commandline.Main ' + this.data.command;

        // Gets valid command line options associated to the Flyway Command which have been entered
        var commandOptions = availableCommands[this.data.command];

{'fraction_non_alphanumeric': 0.10356435643564356, 'fraction_numerical': 0.0028712871287128712, 'mean_word_length': 1.3056379821958457, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '180059', 'n_tokens_mistral': 2456, 'n_tokens_neox': 2273, 'n_words': 629}