<commit_before>import Stack from '../../Stack';


const DB_HOST = 'database';
const DB_DATABASE = 'laravel';
const DB_USERNAME = 'stacker';
const DB_PASSWORD = '<PASSWORD>';
const DEFAULT_OPTIONS = {
  database: 'mariadb',
};

export default class LaravelStack extends Stack {
  constructor(options = {}) {
    super();
    this.setOptions(options);
    this.init();
  }
  setOptions(options) {
    this.options = { ...DEFAULT_OPTIONS, ...options };
  }
  init() {
    this.initLaravelService();
    this.initDatabaseService();
    this.initRedisService();
    this.initMemcachedService();
    this.initBeanstalkdService();
  }
  initLaravelService() {
    this.services.set('laravel', {
      image: 'stacker/laravel:latest',
      shell: '/bin/bash',
      env: {
        DB_HOST,
        DB_DATABASE,
        DB_USERNAME,
        DB_PASSWORD,
      },
      ports: {
        80: 80,
      },
      volumes: [
        '.:/app',
      ],
    });

    this.ejectables.set('apache2.conf', {
      label: 'Apache config',
      path: '/etc/apache2/apache2.conf',
      service: 'laravel',
    });
    this.ejectables.set('apache2-site.conf', {
      label: 'Apache virtual host',
      path: '/etc/apache2/site-available/app.conf',
      service: 'laravel',
    });

    this.runnables.set('apache-reload', {
      label: 'Reload Apache service',
      exec: 'service apache2 reload',
      service: 'laravel',
    });
  }
  initDatabaseService() {
    if (this.options.database === 'mysql') {
      return this.initMysqlService();
    } else if (this.options.database === 'mariadb') {
      return this.initMariadbService();
    } else if (this.options.database === 'postgres') {
      return this.initPostgresService();
    }
  }
  initMysqlService() {
    this.services.set('database', {
      image: 'mysql:latest',
      shell: '/bin/bash',
      env: {
        MYSQL_ROOT_PASSWORD: '<PASSWORD>',
        MYSQL_DATABASE: DB_DATABASE,
        MYSQL_USER: DB_USERNAME,
        MYSQL_PASSWORD: <PASSWORD>,
      },<commit_msg>add phpunit runnable in laravel template<commit_after>import Stack from '../../Stack';


const DB_HOST = 'database';
const DB_DATABASE = 'laravel';
const DB_USERNAME = 'stacker';
const DB_PASSWORD = '<PASSWORD>';
const DEFAULT_OPTIONS = {
  database: 'mariadb',
};

export default class LaravelStack extends Stack {
  constructor(options = {}) {
    super();
    this.setOptions(options);
    this.init();
  }
  setOptions(options) {
    this.options = { ...DEFAULT_OPTIONS, ...options };
  }
  init() {
    this.initLaravelService();
    this.initDatabaseService();
    this.initRedisService();
    this.initMemcachedService();
    this.initBeanstalkdService();
  }
  initLaravelService() {
    this.services.set('laravel', {
      image: 'stacker/laravel:latest',
      shell: '/bin/bash',
      env: {
        DB_HOST,
        DB_DATABASE,
        DB_USERNAME,
        DB_PASSWORD,
      },
      ports: {
        80: 80,
      },
      volumes: [
        '.:/app',
      ],
    });

    this.ejectables.set('apache2.conf', {
      label: 'Apache config',
      path: '/etc/apache2/apache2.conf',
      service: 'laravel',
    });
    this.ejectables.set('apache2-site.conf', {
      label: 'Apache virtual host',
      path: '/etc/apache2/site-available/app.conf',
      service: 'laravel',
    });

    this.runnables.set('apache-reload', {
      label: 'Reload Apache service',
      exec: 'service apache2 reload',
      service: 'laravel',
    });
    this.runnables.set('phpunit', {
      label: 'Run PHPUnit suite',
      exec: './vendor/bin/phpunit; exit $?',
      service: 'laravel',
    });
  }
  initDatabaseService() {
    if (this.options.database === 'mysql') {
      return this.initMysqlService();
    } else if (this.options.database === 'mariadb') {
      return this.initMariadbService();
    } else if (this.options.database === 'postgres') {
      return this.initPostgresService();
    }
  }
  initMysqlService() {
    this.services.set('database', {
      image: 'mysql:latest',
      shell: '/bin/bash',
      env: {
        MYSQL_ROOT_PASSWORD: '<PASSWORD>',
        MYSQL_DATABASE: DB_DATABASE,
        MYSQL_USER: DB_USERNAME,
        MYSQL_PASSWORD: <PASSWORD>,
      },
{'fraction_non_alphanumeric': 0.15586565752128667, 'fraction_numerical': 0.004730368968779565, 'mean_word_length': 2.568776371308017, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '806504', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1396, 'n_words': 249}