You are here

function site_audit_drush_command in Site Audit 7

Same name and namespace in other branches
  1. 8.2 site_audit.drush.inc \site_audit_drush_command()

Implements hook_drush_command().

File

./site_audit.drush.inc, line 54
Drupal site auditing commands.

Code

function site_audit_drush_command() {
  $items = array();
  $vendor_options = array(
    'vendor' => array(
      'description' => dt("If used, will adjust recommendations based on a Vendor's specific needs. Currently supported: pantheon"),
      'example-value' => dt('pantheon'),
      'value' => 'required',
    ),
  );
  $options_all = array_merge(site_audit_common_options(), $vendor_options);
  $arguments_all = array();
  $items['audit_best_practices'] = array(
    'description' => dt('Audit best practices used.'),
    'aliases' => array(
      'abp',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => array_merge(site_audit_common_options(), $vendor_options),
    'checks' => array(
      'Multisite',
      'Settings',
      'SitesDefault',
      'SitesAll',
      'SitesSuperfluous',
      'Fast404',
      'PhpFilter',
    ),
  );
  $items['audit_block'] = array(
    'description' => dt('Audit Block.'),
    'aliases' => array(
      'ab',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'Enabled',
      'Cache',
      'CacheReport',
    ),
  );
  $items['audit_cache'] = array(
    'description' => dt('Audit Drupal\'s caching settings.'),
    'aliases' => array(
      'ac',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => array_merge(site_audit_common_options(), $vendor_options),
    'checks' => array(
      'Anon',
      'Lifetime',
      'PageExpire',
      'PageCompression',
      'PreprocessCss',
      'PreprocessJs',
      'Lock',
      'Backends',
      'DefaultClass',
      'Bins',
    ),
  );
  $items['audit_codebase'] = array(
    'description' => dt('Audit the codebase.'),
    'aliases' => array(
      'acb',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'SizeFiles',
      'SizeAll',
      'ManagedFileCount',
      'ManagedFileSize',
    ),
  );
  $items['audit_content'] = array(
    'description' => dt('Audit content.'),
    'aliases' => array(
      'acn',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'ContentTypes',
      'ContentTypesUnused',
      'DuplicateTitles',
      'Vocabularies',
      'VocabulariesUnused',
      'FieldEnabled',
      'FieldCount',
      'FieldInstances',
      'FieldsUnused',
    ),
  );
  $items['audit_cron'] = array(
    'description' => dt('Audit cron.'),
    'aliases' => array(
      'acr',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'Enabled',
      'Running',
      'Last',
    ),
  );
  $options_db = array(
    'min_rows' => array(
      'description' => dt('Minimum number of rows to check for. Defaults to 1000.'),
      'example-value' => dt('1000'),
      'value' => 'required',
    ),
  );
  $options_all = array_merge($options_all, $options_db);
  $items['audit_database'] = array(
    'description' => dt('Report information about a site environment\'s database.'),
    'aliases' => array(
      'ad',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => array_merge(site_audit_common_options(), $options_db),
    'checks' => array(
      'Size',
      'RowCount',
      'Collation',
      'Engine',
    ),
  );
  $items['audit_extensions'] = array(
    'description' => dt('Audit extensions (modules and themes).'),
    'aliases' => array(
      'ae',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => array_merge(site_audit_common_options(), $vendor_options),
    'checks' => array(
      'Count',
      'Dev',
      'Unrecommended',
      'Redundant',
      'Duplicate',
      'Missing',
      'Disabled',
      'Update',
      'Security',
    ),
  );
  $items['audit_extensions']['options']['extension_count'] = array(
    'description' => dt('Specify threshold for average number of extensions'),
    'example-value' => dt('150'),
    'value' => 'required',
  );
  $arguments_gi = array(
    'url' => dt('The URL that you wish to test.'),
    'key' => dt('Google Code API Key - see https://developers.google.com/speed/docs/insights/v1/getting_started#auth'),
  );
  $arguments_all = array_merge($arguments_all, $arguments_gi);
  $options_gi = array(
    'impact' => array(
      'description' => dt('Only show results with an impact greater than what\'s specified. 3 is considered high impact.'),
      'example-value' => dt('3'),
      'value' => 'required',
    ),
    'limit' => array(
      'description' => dt('Limit the number of records shown for each item.'),
      'example-value' => dt('3'),
      'value' => 'required',
    ),
  );
  $options_all = array_merge($options_all, $options_gi);
  $items['audit_insights'] = array(
    'description' => dt('Analyze a site using Google PageSpeed Insights.'),
    'aliases' => array(
      'agi',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'arguments' => $arguments_gi,
    'options' => array_merge(site_audit_common_options(), $options_gi),
    'checks' => array(
      'Analyze',
    ),
  );
  $items['audit_front_end'] = array(
    'description' => dt("Analyze a site's front end performance."),
    'aliases' => array(
      'afe',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'TemplateFiles',
    ),
  );
  $items['audit_security'] = array(
    'description' => dt('Audit the site for known security vulnerabilities.'),
    'aliases' => array(
      'asec',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'MenuRouter',
    ),
  );
  $items['audit_status'] = array(
    'description' => dt('Audit Drupal\'s built-in status report.'),
    'aliases' => array(
      'as',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'System',
    ),
  );
  $items['audit_users'] = array(
    'description' => dt('Audit Users.'),
    'aliases' => array(
      'au',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'CountAll',
      'CountBlocked',
      'WhoIsNumberOne',
      'BlockedNumberOne',
    ),
  );
  $items['audit_roles'] = array(
    'description' => dt('Audit Roles.'),
    'aliases' => array(
      'ar',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'RolesList',
      'RolesPermissions',
    ),
  );
  $items['audit_views'] = array(
    'description' => dt('Audit Views.'),
    'aliases' => array(
      'av',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => site_audit_common_options(),
    'checks' => array(
      'Enabled',
      'Count',
      'CacheResults',
      'CacheOutput',
    ),
  );
  $items['audit_watchdog'] = array(
    'description' => dt('Audit the database logs.'),
    'aliases' => array(
      'aw',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'options' => array_merge(site_audit_common_options(), $vendor_options),
    'checks' => array(
      'Syslog',
      'Enabled',
      'Count',
      'Age',
      '404',
      'Php',
    ),
  );
  $arguments_all['key'] = dt('URL for Site Audit Report, also used for Google PageSpeed Insights report.');
  $items['audit_all'] = array(
    'description' => dt('Executes every Site Audit Report'),
    'aliases' => array(
      'aa',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'arguments' => $arguments_all,
    'options' => $options_all,
    'reports' => array(
      'BestPractices',
      'Block',
      'Cache',
      'Codebase',
      'Content',
      'Cron',
      'Database',
      'Extensions',
      'Insights',
      'Security',
      'Status',
      'Users',
      'Views',
      'Watchdog',
    ),
  );
  $items['site-audit-version'] = array(
    'description' => dt('Show the Site Audit version.'),
    'callback' => 'drush_site_audit_site_audit_version',
    'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
  );
  return $items;
}