<commit_before>const path = require('path');
const _ = require('lodash');
const Promise = require('bluebird');
const SailsIntegration = require('./sails_integration');

const sailsToKnexClient = {
  'sails-postgresql': 'pg',
  'sails-mysql': 'mysql'
};

function getModulesPath(basePath) {
  const baseAppPath = basePath || process.cwd();
  return path.join(baseAppPath, 'node_modules');
}

function getClientFromSailsConfig(sailsConfig) {
  var adapter;
  switch(sailsConfig.defaultAdapter.version) {
    case '0.10':
      adapter = sailsConfig.defaultAdapter.config.adapter;
      break;
    case '0.9':
      adapter = sailsConfig.defaultAdapter.identity;
      break;
  }
  return sailsToKnexClient[adapter];
}

function getConfigFromSailsConfig(sailsConfig) {
  const fullConfig = _.defaults({}, sailsConfig.defaultAdapter.config, sailsConfig.defaultAdapter.defaults);
  const client = getClientFromSailsConfig(sailsConfig);
  const connection = {
    host: fullConfig.host,
    user: fullConfig.user,
    port: fullConfig.port,
    database: fullConfig.database,
    password: <PASSWORD>
  };

  const migrations = {
    tableName: 'sails_migrations',
    directory: './db/migrations'
  };

  const result = {
    client: client,
    connection: connection,
    migrations: migrations
  };<commit_msg>Fix knex client setup for sails 0.11.x<commit_after>const path = require('path');
const _ = require('lodash');
const Promise = require('bluebird');
const SailsIntegration = require('./sails_integration');

const sailsToKnexClient = {
  'sails-postgresql': 'pg',
  'sails-mysql': 'mysql'
};

function getModulesPath(basePath) {
  const baseAppPath = basePath || process.cwd();
  return path.join(baseAppPath, 'node_modules');
}

function getClientFromSailsConfig(sailsConfig) {
  var version = sailsConfig.defaultAdapter.version;
  var adapter;
  if (version === '0.10' || version === '0.11') {
    adapter = sailsConfig.defaultAdapter.config.adapter;
  } else if (version === '0.9')
    adapter = sailsConfig.defaultAdapter.identity;
  }
  return sailsToKnexClient[adapter];
}

function getConfigFromSailsConfig(sailsConfig) {
  const fullConfig = _.defaults({}, sailsConfig.defaultAdapter.config, sailsConfig.defaultAdapter.defaults);
  const client = getClientFromSailsConfig(sailsConfig);
  const connection = {
    host: fullConfig.host,
    user: fullConfig.user,
    port: fullConfig.port,
    database: fullConfig.database,
    password: <PASSWORD>
  };

  const migrations = {
    tableName: 'sails_migrations',
    directory: './db/migrations'
  };

  const result = {
    client: client,
    connection: connection,
    migrations: migrations
  };
{'fraction_non_alphanumeric': 0.12570356472795496, 'fraction_numerical': 0.00600375234521576, 'mean_word_length': 4.429735234215886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1552410', 'n_tokens_mistral': 835, 'n_tokens_neox': 817, 'n_words': 169}