1.0.0 Alpha Release #59

Merged
netkas merged 213 commits from v1.0.0_alpha into master 2023-01-29 23:27:58 +00:00
Showing only changes of commit 134c26452a - Show all commits

View file

@ -14,8 +14,10 @@
use ncc\Abstracts\ConsoleColors;
use ncc\Exceptions\FileNotFoundException;
use ncc\Managers\RemoteSourcesManager;
use ncc\ncc;
use ncc\Objects\CliHelpSection;
use ncc\Objects\DefinedRemoteSource;
use ncc\ThirdParty\Symfony\Filesystem\Exception\IOException;
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
use ncc\ThirdParty\Symfony\Process\Exception\ProcessFailedException;
@ -818,6 +820,57 @@
return;
}
if($NCC_FILESYSTEM->exists(__DIR__ . DIRECTORY_SEPARATOR . 'repositories'))
{
if(!$NCC_FILESYSTEM->exists(__DIR__ . DIRECTORY_SEPARATOR . 'repositories' . DIRECTORY_SEPARATOR . 'custom_repositories.json'))
return;
try
{
$custom_repositories = Functions::loadJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'repositories' . DIRECTORY_SEPARATOR . 'custom_repositories.json', Functions::FORCE_ARRAY);
}
catch(Exception $e)
{
$custom_repositories = null;
Console::outWarning(sprintf('Failed to load custom repositories: %s', $e->getMessage()));
}
if($custom_repositories !== null)
{
$source_manager = new RemoteSourcesManager();
foreach($custom_repositories as $repository)
{
$repo_path = __DIR__ . DIRECTORY_SEPARATOR . 'repositories' . DIRECTORY_SEPARATOR . $repository;
if($NCC_FILESYSTEM->exists($repo_path))
{
try
{
$definedEntry = DefinedRemoteSource::fromArray(Functions::loadJsonFile($repo_path, Functions::FORCE_ARRAY));
if(!$source_manager->getRemoteSource($definedEntry->Name))
$source_manager->addRemoteSource($definedEntry);
}
catch(Exception $e)
{
Console::outWarning(sprintf('Failed to load custom repository %s: %s', $repository, $e->getMessage()));
}
}
else
{
Console::outWarning(sprintf('Failed to load custom repository %s, file does not exist', $repository));
}
}
try
{
$source_manager->save();
}
catch (\ncc\Exceptions\IOException $e)
{
Console::outWarning(sprintf('Failed to save sources: %s', $e->getMessage()));
}
}
}
Console::out('NCC version: ' . NCC_VERSION_NUMBER . ' has been successfully installed');
Console::out('For licensing information see \'' . $NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'LICENSE\' or run \'ncc help --license\'');