2014-08-31 22:56:25 -07:00
|
|
|
#!/usr/bin/env php
|
|
|
|
|
<?php
|
2014-09-11 13:08:22 -07:00
|
|
|
define('GRAV_CLI', true);
|
2014-08-31 22:56:25 -07:00
|
|
|
|
2015-05-15 19:54:33 +02:00
|
|
|
if (!file_exists(__DIR__ . '/../vendor')){
|
|
|
|
|
require_once __DIR__ . '/../system/src/Grav/Common/Composer.php';
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-14 21:37:47 +02:00
|
|
|
use Grav\Common\Composer;
|
2016-09-01 15:44:43 -06:00
|
|
|
use Grav\Common\Config\Setup;
|
2015-05-14 21:37:47 +02:00
|
|
|
|
2014-09-04 16:29:48 -07:00
|
|
|
if (!file_exists(__DIR__ . '/../vendor')){
|
|
|
|
|
// Before we can even start, we need to run composer first
|
2015-05-15 19:54:33 +02:00
|
|
|
$composer = Composer::getComposerExecutor();
|
2014-09-04 16:29:48 -07:00
|
|
|
echo "Preparing to install vendor dependencies...\n\n";
|
2015-05-15 19:54:33 +02:00
|
|
|
echo system($composer.' --working-dir="'.__DIR__.'/../" --no-interaction --no-dev --prefer-dist -o install');
|
2014-09-04 16:29:48 -07:00
|
|
|
echo "\n\n";
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-31 22:56:25 -07:00
|
|
|
use Symfony\Component\Console\Application;
|
|
|
|
|
use Grav\Common\Grav;
|
|
|
|
|
|
|
|
|
|
$autoload = require_once(__DIR__ . '/../vendor/autoload.php');
|
|
|
|
|
|
2015-12-28 18:46:14 +01:00
|
|
|
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
|
|
|
|
|
exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-31 22:56:25 -07:00
|
|
|
if (!ini_get('date.timezone')) {
|
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!file_exists(ROOT_DIR . 'index.php')) {
|
|
|
|
|
exit('FATAL: Must be run from ROOT directory of Grav!');
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-26 16:39:58 -06:00
|
|
|
if (!function_exists('curl_version')) {
|
|
|
|
|
exit('FATAL: GPM requires PHP Curl module to be installed');
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-01 15:44:43 -06:00
|
|
|
$climate = new League\CLImate\CLImate;
|
|
|
|
|
$climate->arguments->add([
|
|
|
|
|
'environment' => [
|
|
|
|
|
'prefix' => 'e',
|
|
|
|
|
'longPrefix' => 'env',
|
|
|
|
|
'description' => 'Configuration Environment',
|
|
|
|
|
'defaultValue' => 'localhost'
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
$climate->arguments->parse();
|
|
|
|
|
$environment = $climate->arguments->get('environment');
|
|
|
|
|
|
|
|
|
|
// Set up environment based on params.
|
|
|
|
|
Setup::$environment = $environment;
|
|
|
|
|
|
2014-09-11 12:40:53 -07:00
|
|
|
$grav = Grav::instance(array('loader' => $autoload));
|
2016-02-02 10:33:25 -07:00
|
|
|
$grav['uri']->init();
|
2016-09-01 15:44:43 -06:00
|
|
|
$grav['config']->init();
|
2014-10-28 22:29:43 -07:00
|
|
|
$grav['streams'];
|
2014-08-31 22:56:25 -07:00
|
|
|
|
2014-10-01 12:43:12 -07:00
|
|
|
$app = new Application('Grav Package Manager', GRAV_VERSION);
|
2014-08-31 22:57:18 -07:00
|
|
|
$app->addCommands(array(
|
2014-09-04 20:34:36 -07:00
|
|
|
new \Grav\Console\Gpm\IndexCommand(),
|
2014-10-14 12:45:10 -07:00
|
|
|
new \Grav\Console\Gpm\VersionCommand(),
|
2014-09-04 20:34:36 -07:00
|
|
|
new \Grav\Console\Gpm\InfoCommand(),
|
|
|
|
|
new \Grav\Console\Gpm\InstallCommand(),
|
2015-01-01 15:00:26 -08:00
|
|
|
new \Grav\Console\Gpm\UninstallCommand(),
|
2014-09-04 20:34:36 -07:00
|
|
|
new \Grav\Console\Gpm\UpdateCommand(),
|
2014-09-25 18:35:09 -07:00
|
|
|
new \Grav\Console\Gpm\SelfupgradeCommand(),
|
2016-09-18 10:23:55 -06:00
|
|
|
new \Grav\Console\Gpm\DirectInstallCommand(),
|
2014-08-31 22:57:18 -07:00
|
|
|
));
|
2016-01-11 18:45:07 -07:00
|
|
|
|
2014-08-31 22:56:25 -07:00
|
|
|
$app->run();
|