<commit_before><?php

$baseDir = realpath(__DIR__ . "/../");
$pwDir = realpath($baseDir . "/vendor/processwire/processwire/");

// load dependencies
require_once $baseDir . "/vendor/autoload.php";

use ProcessWire\ProcessWire;

$wireConfig = ProcessWire::buildConfig($pwDir, null, [
"siteDir" => "site-default"
]);
$wire = new ProcessWire($wireConfig);

// =====================
// Setup GraphiQL Assets
// =====================
$config = $wire->fuel('config');

$scripts = scandir(realpath(__DIR__  . "/../GraphiQL/build/static/js"));
$scripts = array_walk($scripts, function ($filename) use ($config) {
  if (preg_match('/^main\..*\.js$/', $filename)) {
    $config->scripts->add(realpath(__DIR__ . "/../GraphiQL/build/static/js/{$filename}"));
  }
});

$styles = scandir(realpath(__DIR__  . "/../GraphiQL/build/static/css"));
$styles = array_walk($styles, function ($filename) use ($config) {
  if (preg_match('/^main\..*\.css$/', $filename)) {
    $config->styles->add(realpath(__DIR__ . "/../GraphiQL/build/static/css/{$filename}"));
  }
});

$config->js('ProcessGraphQL', [
  'GraphQLServerUrl' => 'http://localhost:8081',
]);

?>
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <title>GraphiQL</title>
    <style>
      body {
        height: 100%;
        margin: 0;
        width: 100%;
        overflow: hidden;
      }
      #graphiql {
        height: 100vh;
      }
    </style>
  </head>
  <body>
    <style>
      <?php
        foreach($config->styles as $file) {
          require_once($file);
          echo "\n\n";
        }
      ?>
    </style>
    <div id="graphiql">Loading...</div>
    <script>
      var config = <?= json_encode($config->js()) ?>;
      <?php
        foreach($config->scripts as $file) {
          require_once($file);
          echo ";;\n";
        }
      ?>
    </script>
  </body>
</html><commit_msg>Setup debugging environment.<commit_after><?php

$baseDir = realpath(__DIR__ . "/../");
$pwDir = realpath($baseDir . "/vendor/processwire/processwire/");

// load dependencies
require_once $baseDir . "/vendor/autoload.php";

use ProcessWire\ProcessWire;

$wireConfig = ProcessWire::buildConfig($pwDir, null, [
"siteDir" => "site-default"
]);
$wire = new ProcessWire($wireConfig);

// =====================
// Setup GraphiQL Assets
// =====================
$config = $wire->fuel('config');

$config->js('ProcessGraphQL', [
  'GraphQLServerUrl' => 'http://localhost:8081',
]);

$config->scripts->add("https://cdn.jsdelivr.net/es6-promise/4.0.5/es6-promise.auto.min.js");
$config->scripts->add("https://cdn.jsdelivr.net/fetch/0.9.0/fetch.min.js");
$config->scripts->add("https://cdn.jsdelivr.net/react/15.4.2/react.min.js");
$config->scripts->add("https://cdn.jsdelivr.net/react/15.4.2/react-dom.min.js");
$config->scripts->add('GraphiQL/node_modules/graphiql/graphiql.min.js');
$config->styles->add('GraphiQL/node_modules/graphiql/graphiql.css');

$filename = realpath($baseDir . $_SERVER['SCRIPT_NAME']);
if ($filename === $baseDir) {
  require_once(realpath("$baseDir/GraphiQL/full.php"));
}

if (!file_exists($filename)) {
  http_response_code(404);
  echo "Not Found!";
  return;
}

if (preg_match('/^[a-zA-Z\/_.]+\.js$/', $filename)) {
  header('Content-type: text/javascript');
} else if (preg_match('/^[a-zA-Z\/_.]+\.css$/', $filename)) {
  header('Content-type: text/css');
}
require_once($filename);
{'fraction_non_alphanumeric': 0.2402857142857143, 'fraction_numerical': 0.011142857142857144, 'mean_word_length': 3.630952380952381, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 54, 'https://': 4, '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': '5474821', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1227, 'n_words': 176}