<commit_before><?php

pake_desc('upgrade to a new symfony release');
pake_task('upgrade', 'project_exists');

pake_desc('downgrade to a previous symfony release');
pake_task('downgrade', 'project_exists');

function run_upgrade($task, $args)
{
  if (!isset($args[0]))
  {
    throw new Exception('You must provide the upgrade script to use (0.8 to upgrade to 0.8 for example).');
  }

  $version = $args[0];

   if ($version == '0.8')
   {
     run_upgrade_0_8($task, $args);
   }
   else
   {
     throw new Exception('I have no upgrade script for this release.');
   }
}

function run_upgrade_0_8($task, $args)
{
  // upgrade propel.ini
  _upgrade_0_8_propel_ini();

  // upgrade model classes
  _upgrade_0_8_propel_model();

  // find all applications for this project
  $apps = pakeFinder::type('directory')->name(sfConfig::get('sf_app_module_dir_name'))->mindepth(1)->maxdepth(1)->relative()->in(sfConfig::get('sf_apps_dir_name'));

  // upgrade all applications
  foreach ($apps as $app_module_dir)
  {
    $app = str_replace(DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_dir_name'), '', $app_module_dir);
    pake_echo_action('upgrade 0.8', sprintf('[upgrading application "%s"]', $app));

    $app_dir = sfConfig::get('sf_apps_dir_name').'/'.$app;

    // upgrade config.php
    _upgrade_0_8_config_php($app_dir);

    // upgrade all modules
    $dir = $app_dir.'/'.sfConfig::get('sf_app_module_dir_name');
    if ($dir)
    {
      // template dirs
      $template_dirs   = pakeFinder::type('directory')->name('templates')->mindepth(1)->maxdepth(1)->in($dir);
      $template_dirs[] = $app_dir.'/'.sfConfig::get('sf_app_template_dir_name');

      _upgrade_0_8_deprecated_for_templates($template_dirs);

      _upgrade_0_8_deprecated_for_generator($app_dir);

      // actions dirs
      $action_dirs = pakeFinder::type('directory')->name('actions')->mindepth(1)->maxdepth(1)->in($dir);

      _upgrade_0_8_deprecated_for_actions($action_dirs);
    }
  }

  pake_echo_action('upgrade 0.8', 'done');
  pake_echo_comment('you can now:');
  pake_echo_comment(' - rebuild model: symfony propel-build-model');
  pake_echo_comment(' - clear cache: symfony cc');
}

function _upgrade_0_8_deprecated_for_generator($app_dir)<commit_msg>added a warning to pake upgrade if a project has some plugins installed<commit_after><?php

pake_desc('upgrade to a new symfony release');
pake_task('upgrade', 'project_exists');

pake_desc('downgrade to a previous symfony release');
pake_task('downgrade', 'project_exists');

function run_upgrade($task, $args)
{
  if (!isset($args[0]))
  {
    throw new Exception('You must provide the upgrade script to use (0.8 to upgrade to 0.8 for example).');
  }

  $version = $args[0];

   if ($version == '0.8')
   {
     run_upgrade_0_8($task, $args);
   }
   else
   {
     throw new Exception('I have no upgrade script for this release.');
   }
}

function run_upgrade_0_8($task, $args)
{
  // upgrade propel.ini
  _upgrade_0_8_propel_ini();

  // upgrade model classes
  _upgrade_0_8_propel_model();

  // find all applications for this project
  $apps = pakeFinder::type('directory')->name(sfConfig::get('sf_app_module_dir_name'))->mindepth(1)->maxdepth(1)->relative()->in(sfConfig::get('sf_apps_dir_name'));

  // upgrade all applications
  foreach ($apps as $app_module_dir)
  {
    $app = str_replace(DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_dir_name'), '', $app_module_dir);
    pake_echo_action('upgrade 0.8', sprintf('[upgrading application "%s"]', $app));

    $app_dir = sfConfig::get('sf_apps_dir_name').'/'.$app;

    // upgrade config.php
    _upgrade_0_8_config_php($app_dir);

    // upgrade all modules
    $dir = $app_dir.'/'.sfConfig::get('sf_app_module_dir_name');
    if ($dir)
    {
      // template dirs
      $template_dirs   = pakeFinder::type('directory')->name('templates')->mindepth(1)->maxdepth(1)->in($dir);
      $template_dirs[] = $app_dir.'/'.sfConfig::get('sf_app_template_dir_name');

      _upgrade_0_8_deprecated_for_templates($template_dirs);

      _upgrade_0_8_deprecated_for_generator($app_dir);

      // actions dirs
      $action_dirs = pakeFinder::type('directory')->name('actions')->mindepth(1)->maxdepth(1)->in($dir);

      _upgrade_0_8_deprecated_for_actions($action_dirs);
    }
  }

  pake_echo_action('upgrade 0.8', 'done');

  pake_mkdirs(sfConfig::get('sf_root_dir').'/plugins');
  if (is_dir(sfConfig::get('sf_lib_dir').'/plugins'))
  {
    pake_echo_comment('WARNING: you must re-install all your plugins');
  }

  pake_echo_comment('you can now:');
  pake_echo_comment(' - rebuild model: symfony propel-build-model');
  pake_echo_comment(' - clear cache: symfony cc');
}

function _upgrade_0_8_deprecated_for_generator($app_dir)
{'fraction_non_alphanumeric': 0.15947546531302875, 'fraction_numerical': 0.015228426395939087, 'mean_word_length': 4.670263788968825, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '3838686', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1646, 'n_words': 289}