Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 78bfede

Browse files
committed
A lot of work on platform detection code
1 parent 48e8093 commit 78bfede

19 files changed

+424
-7
lines changed

box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"finder": [
1111
{
1212
"name": "*.php",
13-
"exclude": ["Tests", "kherge"],
13+
"exclude": ["Tests", "Tester"],
1414
"in": "vendor"
1515
}
1616
],

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"license": "MIT",
66
"require": {
77
"php": "5.*,>=5.5.9",
8-
"symfony/console": "~3.0"
8+
"symfony/console": "~3.0",
9+
"seld/cli-prompt": "~1.0"
910
},
1011
"require-dev": {},
1112
"autoload": {

src/Command/Command.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
4+
namespace Litipk\JupyterPhpInstaller\Command;
5+
6+
7+
use Litipk\JupyterPhpInstaller\Console\Application;
8+
use Litipk\JupyterPhpInstaller\IO\IOInterface;
9+
10+
use Litipk\JupyterPhpInstaller\IO\NullIO;
11+
use Symfony\Component\Console\Command\Command as BaseCommand;
12+
13+
14+
abstract class Command extends BaseCommand
15+
{
16+
/** @var IOInterface */
17+
private $io;
18+
19+
public function getIO()
20+
{
21+
if (null === $this->io) {
22+
$application = $this->getApplication();
23+
24+
if ($application instanceof Application) {
25+
$this->io = $application->getIO();
26+
} else {
27+
$this->io = new NullIO();
28+
}
29+
}
30+
31+
return $this->io;
32+
}
33+
}

src/Command/InfoCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
namespace Litipk\JupyterPhpInstaller\Command;
55

66

7-
use Symfony\Component\Console\Command\Command;
87
use Symfony\Component\Console\Input\InputArgument;
98
use Symfony\Component\Console\Input\InputInterface;
109
use Symfony\Component\Console\Input\InputOption;

src/Command/InstallCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Litipk\JupyterPhpInstaller\Command;
55

66

7-
use Symfony\Component\Console\Command\Command;
7+
use Litipk\JupyterPhpInstaller\Installer\Installer;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputInterface;
1010
use Symfony\Component\Console\Input\InputOption;
@@ -41,6 +41,9 @@ protected function configure()
4141

4242
protected function execute(InputInterface $input, OutputInterface $output)
4343
{
44+
$installPath = ($input->hasArgument('path')) ? $input->getArgument('path') : null;
45+
$composerCmd = ($input->hasArgument('composer_cmd')) ? $input->getArgument('composer_cmd') : null;
4446

47+
$installer = Installer::getInstaller($installPath, $composerCmd);
4548
}
4649
}

src/Command/UninstallCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
namespace Litipk\JupyterPhpInstaller\Command;
55

66

7-
use Symfony\Component\Console\Command\Command;
87
use Symfony\Component\Console\Input\InputArgument;
98
use Symfony\Component\Console\Input\InputInterface;
109
use Symfony\Component\Console\Input\InputOption;

src/Command/UpdateCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
namespace Litipk\JupyterPhpInstaller\Command;
55

66

7-
use Symfony\Component\Console\Command\Command;
87
use Symfony\Component\Console\Input\InputArgument;
98
use Symfony\Component\Console\Input\InputInterface;
109
use Symfony\Component\Console\Input\InputOption;

src/Console/Application.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
final class Application extends BaseApplication
2727
{
2828
/** @var IOInterface */
29-
protected $io;
29+
private $io;
3030

3131
public function __construct()
3232
{
@@ -101,6 +101,14 @@ public function doRun(InputInterface $input, OutputInterface $output)
101101
return parent::doRun($input, $output);
102102
}
103103

104+
/**
105+
* @return IOInterface
106+
*/
107+
public function getIO()
108+
{
109+
return $this->io;
110+
}
111+
104112
/**
105113
* Initializes all the composer commands.
106114
*/

src/IO/NullIO.php

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
3+
/*
4+
* This file is based on a Composer source file.
5+
*
6+
* (c) Nils Adermann <naderman@naderman.de>
7+
* Jordi Boggiano <j.boggiano@seld.be>
8+
* Andres Correa <castarco@litipk.com>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Litipk\JupyterPhpInstaller\IO;
15+
16+
/**
17+
* IOInterface that is not interactive and never writes the output
18+
*
19+
* @author Christophe Coevoet <stof@notk.org>
20+
*/
21+
class NullIO implements IOInterface
22+
{
23+
/**
24+
* {@inheritDoc}
25+
*/
26+
public function isInteractive()
27+
{
28+
return false;
29+
}
30+
31+
/**
32+
* {@inheritDoc}
33+
*/
34+
public function isVerbose()
35+
{
36+
return false;
37+
}
38+
39+
/**
40+
* {@inheritDoc}
41+
*/
42+
public function isVeryVerbose()
43+
{
44+
return false;
45+
}
46+
47+
/**
48+
* {@inheritDoc}
49+
*/
50+
public function isDebug()
51+
{
52+
return false;
53+
}
54+
55+
/**
56+
* {@inheritDoc}
57+
*/
58+
public function isDecorated()
59+
{
60+
return false;
61+
}
62+
63+
/**
64+
* {@inheritDoc}
65+
*/
66+
public function write($messages, $newline = true)
67+
{
68+
}
69+
70+
/**
71+
* {@inheritDoc}
72+
*/
73+
public function writeError($messages, $newline = true)
74+
{
75+
}
76+
77+
/**
78+
* {@inheritDoc}
79+
*/
80+
public function overwrite($messages, $newline = true, $size = 80)
81+
{
82+
}
83+
84+
/**
85+
* {@inheritDoc}
86+
*/
87+
public function overwriteError($messages, $newline = true, $size = 80)
88+
{
89+
}
90+
91+
/**
92+
* {@inheritDoc}
93+
*/
94+
public function ask($question, $default = null)
95+
{
96+
return $default;
97+
}
98+
99+
/**
100+
* {@inheritDoc}
101+
*/
102+
public function askConfirmation($question, $default = true)
103+
{
104+
return $default;
105+
}
106+
107+
/**
108+
* {@inheritDoc}
109+
*/
110+
public function askAndValidate($question, $validator, $attempts = false, $default = null)
111+
{
112+
return $default;
113+
}
114+
115+
/**
116+
* {@inheritDoc}
117+
*/
118+
public function askAndHideAnswer($question)
119+
{
120+
return null;
121+
}
122+
}

src/Installer/Installer.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
4+
namespace Litipk\JupyterPhpInstaller\Installer;
5+
6+
7+
use Litipk\JupyterPhpInstaller\System\System;
8+
9+
abstract class Installer
10+
{
11+
/**
12+
* @param null|string $installPath
13+
* @param null|string $composerCmd
14+
* @return Installer
15+
*/
16+
public static function getInstaller($installPath = null, $composerCmd = null)
17+
{
18+
$system = System::getSystem();
19+
}
20+
}

0 commit comments

Comments
 (0)