Fixed issue #2 (https://git.n64.cc/nosial/ncc/-/issues/2)
This commit is contained in:
parent
b60963fe47
commit
88e92f82c4
2 changed files with 20 additions and 17 deletions
|
@ -37,7 +37,7 @@ use ncc\ThirdParty\Symfony\process\PhpExecutableFinder;
|
|||
# Global Variables
|
||||
$NCC_INSTALL_PATH=DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'ncc';
|
||||
$NCC_DATA_PATH=DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'ncc';
|
||||
$NCC_UPDATE_SOURCE='https://updates.nosial.com/ncc/check_updates?current_version=$VERSION'; # Unused
|
||||
$NCC_COMPOSER_UPDATE_SOURCE='https://getcomposer.org/installer';
|
||||
$NCC_CHECKSUM=__DIR__ . DIRECTORY_SEPARATOR . 'checksum.bin';
|
||||
$NCC_AUTOLOAD=__DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
$NCC_PHP_EXECUTABLE=null;
|
||||
|
@ -154,6 +154,12 @@ use ncc\ThirdParty\Symfony\process\PhpExecutableFinder;
|
|||
}
|
||||
|
||||
// Check if running as root
|
||||
if(function_exists('posix_getuid') == false)
|
||||
{
|
||||
Console::outError('The function posix_getuid() is not available on your system, please make sure the extension `php-common` is installed');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (posix_getuid() !== 0)
|
||||
{
|
||||
Console::outError('You must be running as root');
|
||||
|
@ -463,7 +469,7 @@ use ncc\ThirdParty\Symfony\process\PhpExecutableFinder;
|
|||
|
||||
$fp = fopen($NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'composer-setup.php', 'w+');
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://getcomposer.org/installer');
|
||||
curl_setopt($ch, CURLOPT_URL, $NCC_COMPOSER_UPDATE_SOURCE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
|
@ -491,7 +497,7 @@ use ncc\ThirdParty\Symfony\process\PhpExecutableFinder;
|
|||
}
|
||||
catch(ProcessFailedException $e)
|
||||
{
|
||||
Console::outError('Cannot install compos)er, ' . $e->getMessage());
|
||||
Console::outError('Cannot install composer, ' . $e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -619,11 +625,11 @@ use ncc\ThirdParty\Symfony\process\PhpExecutableFinder;
|
|||
{
|
||||
if(isset($config_obj[$section]))
|
||||
{
|
||||
foreach($value as $section_item)
|
||||
foreach($value as $section_item => $section_value)
|
||||
{
|
||||
if(!isset($config_obj[$section][$section_item]))
|
||||
{
|
||||
$config_obj[$section][$section_item] = $value;
|
||||
$config_obj[$section][$section_item] = $section_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use ncc\Exceptions\ProjectAlreadyExistsException;
|
||||
use ncc\Objects\ProjectConfiguration;
|
||||
use ncc\Objects\ProjectConfiguration\Compiler;
|
||||
use ncc\Symfony\Component\Uid\Uuid;
|
||||
use ncc\ThirdParty\Symfony\Uid\Uuid;
|
||||
use ncc\Utilities\Validate;
|
||||
|
||||
class ProjectManager
|
||||
|
@ -53,9 +53,9 @@
|
|||
* Attempts to resolve the project path from the selected directory
|
||||
* Returns false if the selected directory is not a proper project or an initialized project
|
||||
*
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
private function detectProjectPath(): bool
|
||||
private function detectProjectPath(): void
|
||||
{
|
||||
$selected_directory = $this->SelectedDirectory;
|
||||
|
||||
|
@ -69,7 +69,7 @@
|
|||
// Detect if the folder exists or not
|
||||
if(!file_exists($selected_directory) || !is_dir($selected_directory))
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Detect if project.json exists in the directory
|
||||
|
@ -77,10 +77,7 @@
|
|||
{
|
||||
$this->ProjectPath = $selected_directory;
|
||||
$this->ProjectFilePath = $selected_directory . 'project.json';
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +92,7 @@
|
|||
* @throws MalformedJsonException
|
||||
* @throws ProjectAlreadyExistsException
|
||||
*/
|
||||
public function initializeProject(Compiler $compiler, string $name, string $package, array $options=[])
|
||||
public function initializeProject(Compiler $compiler, string $name, string $package, array $options=[]): void
|
||||
{
|
||||
// Validate the project information first
|
||||
if(!Validate::packageName($package))
|
||||
|
@ -170,9 +167,9 @@
|
|||
switch($option)
|
||||
{
|
||||
case InitializeProjectOptions::CREATE_SOURCE_DIRECTORY:
|
||||
if(!file_exists($source))
|
||||
if(!file_exists($this->ProjectPath . DIRECTORY_SEPARATOR . 'src'))
|
||||
{
|
||||
mkdir($source);
|
||||
mkdir($this->ProjectPath . DIRECTORY_SEPARATOR . 'src');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue