forked from modmore/Gitify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.php
92 lines (82 loc) · 3.19 KB
/
application.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* Make sure dependencies have been installed, and load the autoloader.
*/
$file = $file = dirname(__FILE__) . '/vendor/autoload.php';
if (file_exists($file)) {
require $file;
} else if (!class_exists(modmore\Gitify\Gitify, false)) {
throw new \Exception('Uh oh, it looks like dependencies have not yet been installed with Composer. Please follow the installation instructions at https://github.com/modmore/Gitify/wiki/1.-Installation');
}
/**
* Ensure the timezone is set; otherwise you'll get a shit ton (that's a technical term) of errors.
*/
if (version_compare(phpversion(),'5.3.0') >= 0) {
$tz = @ini_get('date.timezone');
if (empty($tz)) {
date_default_timezone_set(@date_default_timezone_get());
}
}
/**
* Specify the working directory, if it hasn't been set yet.
*/
if (!defined('GITIFY_WORKING_DIR')) {
$cwd = getcwd() . DIRECTORY_SEPARATOR;
$cwd = str_replace('\\', '/', $cwd);
define ('GITIFY_WORKING_DIR', $cwd);
}
/**
* Specify the user home directory, for save cache folder of gitify
*/
if (!defined('GITIFY_CACHE_DIR')) {
$cacheDir = '.gitify';
$home = rtrim(getenv('HOME'), DIRECTORY_SEPARATOR);
if (!$home && isset($_SERVER['HOME'])) {
$home = rtrim($_SERVER['HOME'], DIRECTORY_SEPARATOR);
}
if (!$home && isset($_SERVER['HOMEDRIVE']) && isset($_SERVER['HOMEPATH'])) {
// compatibility to Windows
$home = rtrim($_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH'], DIRECTORY_SEPARATOR);
}
if (!$home) {
// fallback to working directory, if home directory can not be determined
$home = rtrim(GITIFY_WORKING_DIR, DIRECTORY_SEPARATOR);
// in working directory .gitify file contains the main configuration,
// cache folder cannot be with the same name (file systems restricts)
$cacheDir = '.gitify-cache';
}
define('GITIFY_CACHE_DIR', implode(DIRECTORY_SEPARATOR, array($home, $cacheDir, '')));
}
/**
* Load all the commands and create the Gitify instance
*/
use modmore\Gitify\Command\BackupCommand;
use modmore\Gitify\Command\BuildCommand;
use modmore\Gitify\Command\ClearCacheCommand;
use modmore\Gitify\Command\DownloadModxCommand;
use modmore\Gitify\Command\ExtractCommand;
use modmore\Gitify\Command\InitCommand;
use modmore\Gitify\Command\InstallModxCommand;
use modmore\Gitify\Command\InstallPackageCommand;
use modmore\Gitify\Command\RestoreCommand;
use modmore\Gitify\Command\UpgradeModxCommand;
use modmore\Gitify\Gitify;
$composerData = file_get_contents(__DIR__ . "/composer.json");
$composerData = json_decode($composerData, true);
$version = $composerData['version'];
$application = new Gitify('Gitify', $version);
$application->add(new InitCommand);
$application->add(new BuildCommand);
$application->add(new DownloadModxCommand);
$application->add(new ExtractCommand);
$application->add(new InstallModxCommand);
$application->add(new UpgradeModxCommand);
$application->add(new InstallPackageCommand);
$application->add(new BackupCommand);
$application->add(new RestoreCommand);
$application->add(new ClearCacheCommand);
/**
* We return it so the CLI controller in /Gitify can run it, or for other integrations to
* work with the Gitify api directly.
*/
return $application;