<commit_before><?php

return array(
	'arg0'    => 'module:upload',
	'command' => 'module:upload',
	'description' => 'Upload a module to application',
	'run' => function($args) {
		$module_types = array('observers', 'routes', 'templates');

		$client = new Client\Client();
		foreach(Client\Utils::glob(Client\Project::root() . 'dl-ext/**') as $module) {

			if (is_file($module)) {
				$module_type = basename(dirname($module));

				if (!in_array($module_type, $module_types)) {
					// echo "Invalid module type: '{$module_type}'." . PHP_EOL;
					continue;
				}

				// Check for syntax problems before uploading it.
				$lint_output = null;
				$lint_return_code = null;
				exec('php --syntax-check ' . $module, $lint_output, $lint_return_code);
				if ($lint_return_code !== 0) {
					echo "Aborting." . PHP_EOL;
					die();
				}

				echo "Uploading: '{$module}'" . PHP_EOL;

				$uploaded = $client->post('apps/modules', array(
					'module' => array(
						'name' => basename($module),
						'type' => $module_type,
						'code' => file_get_contents($module)
					)
				));

			}
		}

	}
);<commit_msg>output module errors with colors<commit_after><?php

return array(
	'arg0'    => 'module:upload',
	'command' => 'module:upload',
	'description' => 'Upload a module to application',
	'run' => function($args) {
		$module_types = array('observers', 'routes', 'templates');

		$client = new Client\Client();
		foreach(Client\Utils::glob(Client\Project::root() . 'dl-ext/**') as $module) {

			if (is_file($module)) {
				$module_type = basename(dirname($module));

				if (!in_array($module_type, $module_types)) {
					// echo "Invalid module type: '{$module_type}'." . PHP_EOL;
					continue;
				}

				// Check for syntax problems before uploading it.
				$lint_output = null;
				$lint_return_code = null;
				exec('php --syntax-check ' . $module, $lint_output, $lint_return_code);
				if ($lint_return_code !== 0) {
					echo "\033[1;31m"; // red
					echo $lint_output[1] . PHP_EOL;
					echo "\033[0;39m"; // clear color
					echo "Aborting." . PHP_EOL;
					die();
				}

				echo "Uploading: '{$module}'" . PHP_EOL;

				$uploaded = $client->post('apps/modules', array(
					'module' => array(
						'name' => basename($module),
						'type' => $module_type,
						'code' => file_get_contents($module)
					)
				));

			}
		}

	}
);
{'fraction_non_alphanumeric': 0.1875, 'fraction_numerical': 0.007227891156462585, 'mean_word_length': 3.171985815602837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3619243', 'n_tokens_mistral': 1008, 'n_tokens_neox': 809, 'n_words': 170}