- Removed unused exception PackageNotFoundException
in \ncc\Exceptions
in favor of PackageException
- Removed unused exception `ConstantReadonlyException` in `\ncc\Exceptions` in favor of `IntegrityException` & `\InvalidArgumentException` - Removed unused exception `InvalidConstantName` in `\ncc\Exceptions` in favor for `IntegrityException` - Removed unused exception `ComponentDecodeException` in `\ncc\Exceptions` in favor for `IntegrityException` - Removed unused exception `ResourceChecksumException` in `\ncc\Exceptions` in favor for `IntegrityException` - Removed unused exception `AutoloadGeneratorException` in `\ncc\Exceptions` in favor for `IOException` - Removed unused exception `SymlinkException` in `\ncc\Exceptions` in favor for `IOException` - Removed unused exception `PackageLockException` in `\ncc\Exceptions` in favor for `IOException`
This commit is contained in:
parent
cdbc87e4bc
commit
69d7b86534
30 changed files with 299 additions and 717 deletions
|
@ -112,6 +112,7 @@ features.
|
||||||
- Updated `\ncc\Classes > GitClient > cloneRepository()` to throw `GitException` instead of `GitCloneException`
|
- Updated `\ncc\Classes > GitClient > cloneRepository()` to throw `GitException` instead of `GitCloneException`
|
||||||
- Updated `\ncc\Classes > GitClient > checkout()` to throw `GitException` instead of `GitCheckoutException`
|
- Updated `\ncc\Classes > GitClient > checkout()` to throw `GitException` instead of `GitCheckoutException`
|
||||||
- Corrected code-smell and code style issues in `\ncc\Objects > PackageLock`
|
- Corrected code-smell and code style issues in `\ncc\Objects > PackageLock`
|
||||||
|
- Corrected code-smell and code style issues in `\ncc\Classes\PhpExtension > PhpRuntime`
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
||||||
|
@ -158,6 +159,14 @@ features.
|
||||||
- Removed unused exception `MissingDependencyException` in `\ncc\Exceptions` (not used)
|
- Removed unused exception `MissingDependencyException` in `\ncc\Exceptions` (not used)
|
||||||
- Removed unused exception `PackageAlreadyInstalledException` in `\ncc\Exceptions` in favor of `PackageException`
|
- Removed unused exception `PackageAlreadyInstalledException` in `\ncc\Exceptions` in favor of `PackageException`
|
||||||
- Removed unused exception `PackageFetchException` in `\ncc\Exceptions` in favor of `PackageException`
|
- Removed unused exception `PackageFetchException` in `\ncc\Exceptions` in favor of `PackageException`
|
||||||
|
- Removed unused exception `PackageNotFoundException` in `\ncc\Exceptions` in favor of `PackageException`
|
||||||
|
- Removed unused exception `ConstantReadonlyException` in `\ncc\Exceptions` in favor of `IntegrityException` & `\InvalidArgumentException`
|
||||||
|
- Removed unused exception `InvalidConstantName` in `\ncc\Exceptions` in favor for `IntegrityException`
|
||||||
|
- Removed unused exception `ComponentDecodeException` in `\ncc\Exceptions` in favor for `IntegrityException`
|
||||||
|
- Removed unused exception `ResourceChecksumException` in `\ncc\Exceptions` in favor for `IntegrityException`
|
||||||
|
- Removed unused exception `AutoloadGeneratorException` in `\ncc\Exceptions` in favor for `IOException`
|
||||||
|
- Removed unused exception `SymlinkException` in `\ncc\Exceptions` in favor for `IOException`
|
||||||
|
- Removed unused exception `PackageLockException` in `\ncc\Exceptions` in favor for `IOException`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,24 +24,22 @@ AuthenticationException
|
||||||
ResourceNotFoundException
|
ResourceNotFoundException
|
||||||
PROJECT_ALREADY_EXISTS
|
PROJECT_ALREADY_EXISTS
|
||||||
NO_UNITS_FOUND
|
NO_UNITS_FOUND
|
||||||
PACKAGE_NOT_FOUND
|
|
||||||
VERSION_NOT_FOUND
|
VERSION_NOT_FOUND
|
||||||
NO_AVAILABLE_UNITS
|
NO_AVAILABLE_UNITS
|
||||||
|
|
||||||
PackageLockException
|
|
||||||
PACKAGE_LOCK_EXCEPTION
|
|
||||||
|
|
||||||
|
|
||||||
PackageException
|
PackageException
|
||||||
* PACKAGE_PREPARATION_FAILED
|
* PACKAGE_PREPARATION_FAILED
|
||||||
* PACKAGE_PARSING_EXCEPTION
|
* PACKAGE_PARSING_EXCEPTION
|
||||||
PACKAGE_ALREADY_INSTALLED
|
* PACKAGE_ALREADY_INSTALLED
|
||||||
PACKAGE_FETCH_EXCEPTION
|
* PACKAGE_FETCH_EXCEPTION
|
||||||
- MISSING_DEPENDENCY
|
- MISSING_DEPENDENCY
|
||||||
|
* PACKAGE_NOT_FOUND
|
||||||
|
|
||||||
IOException
|
IOException
|
||||||
IO_EXCEPTION
|
* IO_EXCEPTION
|
||||||
SYMLINK_EXCEPTION
|
* AUTOLOADER_GENERATOR_EXCEPTION
|
||||||
|
* SYMLINK_EXCEPTION
|
||||||
|
* PACKAGE_LOCK_EXCEPTION
|
||||||
|
|
||||||
NetworkException
|
NetworkException
|
||||||
* HTTP_EXCEPTION
|
* HTTP_EXCEPTION
|
||||||
|
@ -80,10 +78,10 @@ RuntimeException
|
||||||
USER_ABORTED_OPERATION
|
USER_ABORTED_OPERATION
|
||||||
|
|
||||||
IntegrityException
|
IntegrityException
|
||||||
CONSTANT_READ_ONLY
|
* CONSTANT_READ_ONLY
|
||||||
INVALID_CONSTANT_NAME
|
* INVALID_CONSTANT_NAME
|
||||||
COMPONENT_DECODE_EXCEPTION
|
* COMPONENT_DECODE_EXCEPTION
|
||||||
RESOURCE_CHECKSUM_EXCEPTION
|
* RESOURCE_CHECKSUM_EXCEPTION
|
||||||
|
|
||||||
AutoLoadException
|
AutoLoadException
|
||||||
AUTOLOAD_GENERATOR
|
- AUTOLOAD_GENERATOR
|
|
@ -27,9 +27,7 @@
|
||||||
use ncc\Enums\ConsoleColors;
|
use ncc\Enums\ConsoleColors;
|
||||||
use ncc\Enums\Options\InstallPackageOptions;
|
use ncc\Enums\Options\InstallPackageOptions;
|
||||||
use ncc\Enums\Scopes;
|
use ncc\Enums\Scopes;
|
||||||
use ncc\Exceptions\PackageLockException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\RuntimeException;
|
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
|
||||||
use ncc\Managers\CredentialManager;
|
use ncc\Managers\CredentialManager;
|
||||||
use ncc\Managers\PackageManager;
|
use ncc\Managers\PackageManager;
|
||||||
use ncc\Objects\CliHelpSection;
|
use ncc\Objects\CliHelpSection;
|
||||||
|
@ -376,7 +374,7 @@
|
||||||
{
|
{
|
||||||
$credential->unlock(Console::passwordInput(sprintf('Enter Password for %s: ', $credential->getName())));
|
$credential->unlock(Console::passwordInput(sprintf('Enter Password for %s: ', $credential->getName())));
|
||||||
}
|
}
|
||||||
catch (RuntimeException $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
Console::outException(sprintf('Failed to unlock credential %s', $credential->getName()), $e, 1);
|
Console::outException(sprintf('Failed to unlock credential %s', $credential->getName()), $e, 1);
|
||||||
return;
|
return;
|
||||||
|
@ -507,7 +505,7 @@
|
||||||
{
|
{
|
||||||
$dependency_package = $package_manager->getPackage($dependency->name);
|
$dependency_package = $package_manager->getPackage($dependency->name);
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
unset($e);
|
unset($e);
|
||||||
$dependency_package = null;
|
$dependency_package = null;
|
||||||
|
@ -519,7 +517,7 @@
|
||||||
{
|
{
|
||||||
$dependency_version = $dependency_package->getVersion($dependency->version);
|
$dependency_version = $dependency_package->getVersion($dependency->version);
|
||||||
}
|
}
|
||||||
catch (VersionNotFoundException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
unset($e);
|
unset($e);
|
||||||
$dependency_version = null;
|
$dependency_version = null;
|
||||||
|
@ -596,7 +594,7 @@
|
||||||
*
|
*
|
||||||
* @param $args
|
* @param $args
|
||||||
* @return void
|
* @return void
|
||||||
* @throws VersionNotFoundException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static function uninstallPackage($args): void
|
private static function uninstallPackage($args): void
|
||||||
{
|
{
|
||||||
|
@ -622,7 +620,7 @@
|
||||||
{
|
{
|
||||||
$package_entry = $package_manager->getPackage($selected_package);
|
$package_entry = $package_manager->getPackage($selected_package);
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
Console::outException('PackageLock error', $e, 1);
|
Console::outException('PackageLock error', $e, 1);
|
||||||
return;
|
return;
|
||||||
|
@ -688,7 +686,7 @@
|
||||||
*
|
*
|
||||||
* @param $args
|
* @param $args
|
||||||
* @return void
|
* @return void
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static function uninstallAllPackages($args): void
|
private static function uninstallAllPackages($args): void
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\ProjectAlreadyExistsException;
|
|
||||||
use ncc\Managers\ProjectManager;
|
use ncc\Managers\ProjectManager;
|
||||||
use ncc\Objects\CliHelpSection;
|
use ncc\Objects\CliHelpSection;
|
||||||
use ncc\Objects\ProjectConfiguration\Compiler;
|
use ncc\Objects\ProjectConfiguration\Compiler;
|
||||||
|
@ -217,11 +216,6 @@
|
||||||
Console::outException(sprintf('The project configuration is invalid: %s', $e->getMessage()), $e, 1);
|
Console::outException(sprintf('The project configuration is invalid: %s', $e->getMessage()), $e, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (ProjectAlreadyExistsException $e)
|
|
||||||
{
|
|
||||||
Console::outException('A project has already been initialized in \'' . $current_directory . '\'', $e, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
Console::outException('There was an unexpected error while trying to initialize the project', $e, 1);
|
Console::outException('There was an unexpected error while trying to initialize the project', $e, 1);
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\PackageNotFoundException;
|
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Exceptions\UserAbortedOperationException;
|
use ncc\Exceptions\UserAbortedOperationException;
|
||||||
use ncc\Interfaces\ServiceSourceInterface;
|
use ncc\Interfaces\ServiceSourceInterface;
|
||||||
|
@ -82,7 +81,6 @@
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws NotSupportedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageException
|
* @throws PackageException
|
||||||
* @throws PackageNotFoundException
|
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws UserAbortedOperationException
|
* @throws UserAbortedOperationException
|
||||||
|
@ -118,7 +116,6 @@
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws NotSupportedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageException
|
* @throws PackageException
|
||||||
* @throws PackageNotFoundException
|
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws UserAbortedOperationException
|
* @throws UserAbortedOperationException
|
||||||
*/
|
*/
|
||||||
|
@ -188,7 +185,6 @@
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws NotSupportedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageException
|
* @throws PackageException
|
||||||
* @throws PackageNotFoundException
|
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
*/
|
*/
|
||||||
private static function compilePackages(string $composer_lock_path): array
|
private static function compilePackages(string $composer_lock_path): array
|
||||||
|
@ -228,7 +224,7 @@
|
||||||
$composer_package = $composer_lock->getPackage($package->Name);
|
$composer_package = $composer_lock->getPackage($package->Name);
|
||||||
if ($composer_package === null)
|
if ($composer_package === null)
|
||||||
{
|
{
|
||||||
throw new PackageNotFoundException(sprintf('Package "%s" not found in composer lock file', $package->Name));
|
throw new PackageException(sprintf('Package "%s" not found in composer lock file', $package->Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert it to an NCC project configuration
|
// Convert it to an NCC project configuration
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
use ncc\Exceptions\ConfigurationException;
|
use ncc\Exceptions\ConfigurationException;
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\PackageException;
|
use ncc\Exceptions\PackageException;
|
||||||
use ncc\Exceptions\PackageLockException;
|
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\RunnerExecutionException;
|
use ncc\Exceptions\RunnerExecutionException;
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\VersionNotFoundException;
|
||||||
|
@ -274,7 +273,7 @@
|
||||||
$package = $package_lock_manager->getPackageLock()?->getPackage($dependency->Name);
|
$package = $package_lock_manager->getPackageLock()?->getPackage($dependency->Name);
|
||||||
if($package === null)
|
if($package === null)
|
||||||
{
|
{
|
||||||
throw new PackageLockException('Cannot find package lock for dependency ' . $dependency->Name);
|
throw new IOException('Cannot find package lock for dependency ' . $dependency->Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = $package->getVersion($dependency->Version);
|
$version = $package->getVersion($dependency->Version);
|
||||||
|
@ -294,11 +293,7 @@
|
||||||
$dependency->Source = 'libs' . DIRECTORY_SEPARATOR . sprintf('%s=%s.lib', $dependency->Name, $dependency->Version);
|
$dependency->Source = 'libs' . DIRECTORY_SEPARATOR . sprintf('%s=%s.lib', $dependency->Name, $dependency->Version);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (VersionNotFoundException $e)
|
catch (IOException $e)
|
||||||
{
|
|
||||||
throw new PackageException('Static linking not possible, cannot find version ' . $dependency->Version . ' for dependency ' . $dependency->Name, $e);
|
|
||||||
}
|
|
||||||
catch (PackageLockException $e)
|
|
||||||
{
|
{
|
||||||
throw new PackageException('Static linking not possible, cannot find package lock for dependency ' . $dependency->Name, $e);
|
throw new PackageException('Static linking not possible, cannot find package lock for dependency ' . $dependency->Name, $e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,15 @@
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Enums\ComponentDataType;
|
use ncc\Enums\ComponentDataType;
|
||||||
use ncc\Enums\ComponentFileExtensions;
|
use ncc\Enums\ComponentFileExtensions;
|
||||||
use ncc\Exceptions\ComponentChecksumException;
|
use ncc\Exceptions\IntegrityException;
|
||||||
use ncc\Exceptions\ComponentDecodeException;
|
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\NotSupportedException;
|
use ncc\Exceptions\NotSupportedException;
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\ResourceChecksumException;
|
|
||||||
use ncc\Interfaces\InstallerInterface;
|
use ncc\Interfaces\InstallerInterface;
|
||||||
use ncc\Objects\InstallationPaths;
|
use ncc\Objects\InstallationPaths;
|
||||||
use ncc\Objects\Package;
|
use ncc\Objects\Package;
|
||||||
use ncc\Objects\Package\Component;
|
use ncc\Objects\Package\Component;
|
||||||
|
use ncc\Objects\Package\Resource;
|
||||||
use ncc\ThirdParty\nikic\PhpParser\Comment;
|
use ncc\ThirdParty\nikic\PhpParser\Comment;
|
||||||
use ncc\ThirdParty\nikic\PhpParser\Node;
|
use ncc\ThirdParty\nikic\PhpParser\Node;
|
||||||
use ncc\ThirdParty\nikic\PhpParser\PrettyPrinter\Standard;
|
use ncc\ThirdParty\nikic\PhpParser\PrettyPrinter\Standard;
|
||||||
|
@ -75,8 +74,7 @@
|
||||||
*
|
*
|
||||||
* @param Component $component
|
* @param Component $component
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* @throws ComponentChecksumException
|
* @throws IntegrityException
|
||||||
* @throws ComponentDecodeException
|
|
||||||
* @throws NotSupportedException
|
* @throws NotSupportedException
|
||||||
*/
|
*/
|
||||||
public function processComponent(Package\Component $component): ?string
|
public function processComponent(Package\Component $component): ?string
|
||||||
|
@ -88,7 +86,7 @@
|
||||||
|
|
||||||
if(!$component->validate_checksum())
|
if(!$component->validate_checksum())
|
||||||
{
|
{
|
||||||
throw new ComponentChecksumException('Checksum validation failed for component ' . $component->name . ', the package may be corrupted.');
|
throw new IntegrityException(sprintf('Checksum validation failed for component: %s', $component->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($component->data_types)
|
switch($component->data_types)
|
||||||
|
@ -100,7 +98,7 @@
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
throw new ComponentDecodeException('Cannot decode component: ' . $component->name . ', ' . $e->getMessage(), $e);
|
throw new IntegrityException(sprintf('Cannot decode component: %s, %s', $component->name, $e->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (new Standard())->prettyPrintFile($stmts);
|
return (new Standard())->prettyPrintFile($stmts);
|
||||||
|
@ -137,15 +135,15 @@
|
||||||
/**
|
/**
|
||||||
* Processes the given resource and returns the string representation of the resource
|
* Processes the given resource and returns the string representation of the resource
|
||||||
*
|
*
|
||||||
* @param Package\Resource $resource
|
* @param Resource $resource
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* @throws ResourceChecksumException
|
* @throws IntegrityException
|
||||||
*/
|
*/
|
||||||
public function processResource(Package\Resource $resource): ?string
|
public function processResource(Package\Resource $resource): ?string
|
||||||
{
|
{
|
||||||
if(!$resource->validateChecksum())
|
if(!$resource->validateChecksum())
|
||||||
{
|
{
|
||||||
throw new ResourceChecksumException('Checksum validation failed for resource ' . $resource->Name . ', the package may be corrupted.');
|
throw new IntegrityException('Checksum validation failed for resource ' . $resource->Name . ', the package may be corrupted.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return Base64::decode($resource->Data);
|
return Base64::decode($resource->Data);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -20,14 +20,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Classes\PhpExtension;
|
namespace ncc\Classes\PhpExtension;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Enums\Options\RuntimeImportOptions;
|
use ncc\Enums\Options\RuntimeImportOptions;
|
||||||
use ncc\Classes\NccExtension\ConstantCompiler;
|
use ncc\Classes\NccExtension\ConstantCompiler;
|
||||||
use ncc\Exceptions\ConstantReadonlyException;
|
|
||||||
use ncc\Exceptions\ImportException;
|
use ncc\Exceptions\ImportException;
|
||||||
use ncc\Exceptions\InvalidConstantNameException;
|
use ncc\Exceptions\IntegrityException;
|
||||||
use ncc\Interfaces\RuntimeInterface;
|
use ncc\Interfaces\RuntimeInterface;
|
||||||
use ncc\Objects\PackageLock\VersionEntry;
|
use ncc\Objects\PackageLock\VersionEntry;
|
||||||
use ncc\Objects\ProjectConfiguration\Assembly;
|
use ncc\Objects\ProjectConfiguration\Assembly;
|
||||||
|
@ -54,7 +53,9 @@ namespace ncc\Classes\PhpExtension;
|
||||||
$assembly_path = $versionEntry->getInstallPaths()->getDataPath() . DIRECTORY_SEPARATOR . 'assembly';
|
$assembly_path = $versionEntry->getInstallPaths()->getDataPath() . DIRECTORY_SEPARATOR . 'assembly';
|
||||||
|
|
||||||
if(!file_exists($assembly_path))
|
if(!file_exists($assembly_path))
|
||||||
|
{
|
||||||
throw new ImportException('Cannot locate assembly file \'' . $assembly_path . '\'');
|
throw new ImportException('Cannot locate assembly file \'' . $assembly_path . '\'');
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -85,30 +86,28 @@ namespace ncc\Classes\PhpExtension;
|
||||||
{
|
{
|
||||||
Constants::register($assembly->package, $name, $value, true);
|
Constants::register($assembly->package, $name, $value, true);
|
||||||
}
|
}
|
||||||
catch (ConstantReadonlyException $e)
|
catch (IntegrityException $e)
|
||||||
{
|
{
|
||||||
trigger_error('Constant \'' . $name . '\' is readonly (' . $assembly->package . ')', E_USER_WARNING);
|
trigger_error('Cannot set constant \'' . $name . '\', ' . $e->getMessage(), E_USER_WARNING);
|
||||||
}
|
|
||||||
catch (InvalidConstantNameException $e)
|
|
||||||
{
|
|
||||||
throw new ImportException('Invalid constant name \'' . $name . '\' (' . $assembly->package . ')', $e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($autoload_path) && !in_array(RuntimeImportOptions::IMPORT_AUTOLOADER, $options))
|
if(file_exists($autoload_path) && !in_array(RuntimeImportOptions::IMPORT_AUTOLOADER, $options, true))
|
||||||
{
|
{
|
||||||
require_once($autoload_path);
|
require_once($autoload_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($static_files) && !in_array(RuntimeImportOptions::IMPORT_STATIC_FILES, $options))
|
if(file_exists($static_files) && !in_array(RuntimeImportOptions::IMPORT_STATIC_FILES, $options, true))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$static_files = ZiProto::decode(IO::fread($static_files));
|
$static_files = ZiProto::decode(IO::fread($static_files));
|
||||||
foreach($static_files as $file)
|
foreach($static_files as $file)
|
||||||
|
{
|
||||||
require_once($file);
|
require_once($file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
throw new ImportException('Failed to load static files: ' . $e->getMessage(), $e);
|
throw new ImportException('Failed to load static files: ' . $e->getMessage(), $e);
|
||||||
|
@ -116,9 +115,6 @@ namespace ncc\Classes\PhpExtension;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!file_exists($autoload_path) && !file_exists($static_files))
|
return !(!file_exists($autoload_path) && !file_exists($static_files));
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -43,46 +43,21 @@
|
||||||
*/
|
*/
|
||||||
public const CONSTANT_READ_ONLY = -1709;
|
public const CONSTANT_READ_ONLY = -1709;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ProjectAlreadyExistsException
|
|
||||||
*/
|
|
||||||
public const PROJECT_ALREADY_EXISTS = -1713;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see AutoloadGeneratorException
|
|
||||||
*/
|
|
||||||
public const AUTOLOAD_GENERATOR = -1714;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NoUnitsFoundException
|
* @see NoUnitsFoundException
|
||||||
*/
|
*/
|
||||||
public const NO_UNITS_FOUND = -1715;
|
public const NO_UNITS_FOUND = -1715;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see InvalidConstantNameException
|
|
||||||
*/
|
|
||||||
public const INVALID_CONSTANT_NAME = -1719;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BuildException
|
* @see BuildException
|
||||||
*/
|
*/
|
||||||
public const BUILD_EXCEPTION = -1727;
|
public const BUILD_EXCEPTION = -1727;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PackageLockException
|
|
||||||
*/
|
|
||||||
public const PACKAGE_LOCK_EXCEPTION = -1729;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see InstallationException
|
* @see InstallationException
|
||||||
*/
|
*/
|
||||||
public const INSTALLATION_EXCEPTION = -1730;
|
public const INSTALLATION_EXCEPTION = -1730;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ComponentDecodeException
|
|
||||||
*/
|
|
||||||
public const COMPONENT_DECODE_EXCEPTION = -1732;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IOException
|
* @see IOException
|
||||||
*/
|
*/
|
||||||
|
@ -103,11 +78,6 @@
|
||||||
*/
|
*/
|
||||||
public const NO_AVAILABLE_UNITS = -1742;
|
public const NO_AVAILABLE_UNITS = -1742;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PackageNotFoundException
|
|
||||||
*/
|
|
||||||
public const PACKAGE_NOT_FOUND = -1745;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ComposerException
|
* @see ComposerException
|
||||||
*/
|
*/
|
||||||
|
@ -138,11 +108,6 @@
|
||||||
*/
|
*/
|
||||||
public const ARCHIVE_EXCEPTION = -1764;
|
public const ARCHIVE_EXCEPTION = -1764;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SymlinkException
|
|
||||||
*/
|
|
||||||
public const SYMLINK_EXCEPTION = -1768;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PathNotFoundException
|
* @see PathNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@ -168,6 +133,11 @@
|
||||||
*/
|
*/
|
||||||
public const NETWORK_EXCEPTION = -1774;
|
public const NETWORK_EXCEPTION = -1774;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IntegrityException
|
||||||
|
*/
|
||||||
|
public const INTEGRITY_EXCEPTION = -1775;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the exception codes from NCC
|
* All the exception codes from NCC
|
||||||
*/
|
*/
|
||||||
|
@ -175,29 +145,23 @@
|
||||||
self::MALFORMED_JSON,
|
self::MALFORMED_JSON,
|
||||||
self::RUNTIME,
|
self::RUNTIME,
|
||||||
self::CONSTANT_READ_ONLY,
|
self::CONSTANT_READ_ONLY,
|
||||||
self::PROJECT_ALREADY_EXISTS,
|
|
||||||
self::AUTOLOAD_GENERATOR,
|
|
||||||
self::NO_UNITS_FOUND,
|
self::NO_UNITS_FOUND,
|
||||||
self::INVALID_CONSTANT_NAME,
|
|
||||||
self::BUILD_EXCEPTION,
|
self::BUILD_EXCEPTION,
|
||||||
self::PACKAGE_LOCK_EXCEPTION,
|
|
||||||
self::INSTALLATION_EXCEPTION,
|
self::INSTALLATION_EXCEPTION,
|
||||||
self::COMPONENT_DECODE_EXCEPTION,
|
|
||||||
self::IO_EXCEPTION,
|
self::IO_EXCEPTION,
|
||||||
self::VERSION_NOT_FOUND,
|
self::VERSION_NOT_FOUND,
|
||||||
self::RUNNER_EXECUTION_EXCEPTION,
|
self::RUNNER_EXECUTION_EXCEPTION,
|
||||||
self::NO_AVAILABLE_UNITS,
|
self::NO_AVAILABLE_UNITS,
|
||||||
self::PACKAGE_NOT_FOUND,
|
|
||||||
self::COMPOSER_EXCEPTION,
|
self::COMPOSER_EXCEPTION,
|
||||||
self::USER_ABORTED_OPERATION,
|
self::USER_ABORTED_OPERATION,
|
||||||
self::AUTHENTICATION_EXCEPTION,
|
self::AUTHENTICATION_EXCEPTION,
|
||||||
self::NOT_SUPPORTED_EXCEPTION,
|
self::NOT_SUPPORTED_EXCEPTION,
|
||||||
self::ARCHIVE_EXCEPTION,
|
self::ARCHIVE_EXCEPTION,
|
||||||
self::SYMLINK_EXCEPTION,
|
|
||||||
self::PATH_NOT_FOUND,
|
self::PATH_NOT_FOUND,
|
||||||
self::GIT_EXCEPTION,
|
self::GIT_EXCEPTION,
|
||||||
self::CONFIGURATION_EXCEPTION,
|
self::CONFIGURATION_EXCEPTION,
|
||||||
self::PACKAGE_EXCEPTION,
|
self::PACKAGE_EXCEPTION,
|
||||||
self::NETWORK_EXCEPTION
|
self::NETWORK_EXCEPTION,
|
||||||
|
self::INTEGRITY_EXCEPTION
|
||||||
];
|
];
|
||||||
}
|
}
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class AutoloadGeneratorException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::AUTOLOAD_GENERATOR, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class ComponentDecodeException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::COMPONENT_DECODE_EXCEPTION, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
|
|
||||||
class ComposerNotAvailableException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::COMPOSER_NOT_AVAILABLE, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class ConstantReadonlyException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::ConstantReadonlyException, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
34
src/ncc/Exceptions/IntegrityException.php
Normal file
34
src/ncc/Exceptions/IntegrityException.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||||
|
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||||
|
* of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ncc\Exceptions;
|
||||||
|
|
||||||
|
use ncc\Enums\ExceptionCodes;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class IntegrityException extends \Exception
|
||||||
|
{
|
||||||
|
public function __construct(string $message = "", ?Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct($message, ExceptionCodes::INTEGRITY_EXCEPTION, $previous);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class InvalidConstantNameException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::INVALID_CONSTANT_NAME, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class PackageLockException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::PACKAGE_LOCK_EXCEPTION, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class PackageNotFoundException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::PACKAGE_NOT_FOUND, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class ProjectAlreadyExistsException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::PROJECT_ALREADY_EXISTS, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class ResourceChecksumException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param int $code
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, $code, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
||||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
||||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
|
||||||
* of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ncc\Enums\ExceptionCodes;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class SymlinkException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::SYMLINK_EXCEPTION, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,7 +24,6 @@ namespace ncc\Interfaces;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Exceptions\ComponentChecksumException;
|
use ncc\Exceptions\ComponentChecksumException;
|
||||||
use ncc\Exceptions\ComponentDecodeException;
|
|
||||||
use ncc\Objects\InstallationPaths;
|
use ncc\Objects\InstallationPaths;
|
||||||
use ncc\Objects\Package;
|
use ncc\Objects\Package;
|
||||||
use ncc\Objects\Package\Component;
|
use ncc\Objects\Package\Component;
|
||||||
|
@ -44,7 +43,6 @@ namespace ncc\Interfaces;
|
||||||
* @param Component $component
|
* @param Component $component
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* @throws ComponentChecksumException
|
* @throws ComponentChecksumException
|
||||||
* @throws ComponentDecodeException
|
|
||||||
*/
|
*/
|
||||||
public function processComponent(Package\Component $component): ?string;
|
public function processComponent(Package\Component $component): ?string;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -20,11 +20,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Interfaces;
|
namespace ncc\Interfaces;
|
||||||
|
|
||||||
use ncc\Exceptions\PackageLockException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\PackageNotFoundException;
|
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
|
||||||
use ncc\Objects\PackageLock\VersionEntry;
|
use ncc\Objects\PackageLock\VersionEntry;
|
||||||
|
|
||||||
interface RuntimeInterface
|
interface RuntimeInterface
|
||||||
|
@ -33,9 +31,7 @@ namespace ncc\Interfaces;
|
||||||
* @param VersionEntry $versionEntry
|
* @param VersionEntry $versionEntry
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws PackageNotFoundException
|
* @throws IOException
|
||||||
* @throws VersionNotFoundException
|
|
||||||
* @throws PackageLockException
|
|
||||||
*/
|
*/
|
||||||
public static function import(VersionEntry $versionEntry, array $options=[]): bool;
|
public static function import(VersionEntry $versionEntry, array $options=[]): bool;
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace ncc\Managers;
|
namespace ncc\Managers;
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
||||||
use ncc\Enums\Scopes;
|
use ncc\Enums\Scopes;
|
||||||
use ncc\Exceptions\AuthenticationException;
|
use ncc\Exceptions\AuthenticationException;
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\PackageLockException;
|
|
||||||
use ncc\Objects\PackageLock;
|
use ncc\Objects\PackageLock;
|
||||||
use ncc\Utilities\Console;
|
use ncc\Utilities\Console;
|
||||||
use ncc\Utilities\IO;
|
use ncc\Utilities\IO;
|
||||||
|
@ -61,7 +60,7 @@
|
||||||
{
|
{
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
unset($e);
|
unset($e);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,7 @@
|
||||||
* Loads the PackageLock from the disk
|
* Loads the PackageLock from the disk
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function load(): void
|
public function load(): void
|
||||||
{
|
{
|
||||||
|
@ -89,7 +88,7 @@
|
||||||
{
|
{
|
||||||
Console::outDebug('package lock exists, loading from disk');
|
Console::outDebug('package lock exists, loading from disk');
|
||||||
$data = IO::fread($this->PackageLockPath);
|
$data = IO::fread($this->PackageLockPath);
|
||||||
if(strlen($data) > 0)
|
if($data !== '')
|
||||||
{
|
{
|
||||||
$this->PackageLock = PackageLock::fromArray(ZiProto::decode($data));
|
$this->PackageLock = PackageLock::fromArray(ZiProto::decode($data));
|
||||||
}
|
}
|
||||||
|
@ -100,7 +99,7 @@
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
throw new PackageLockException('The PackageLock file cannot be parsed', $e);
|
throw new IOException('The PackageLock file cannot be parsed', $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -118,14 +117,14 @@
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function save(): void
|
public function save(): void
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('saving package lock to \'%s\'', $this->PackageLockPath));
|
Console::outDebug(sprintf('saving package lock to \'%s\'', $this->PackageLockPath));
|
||||||
|
|
||||||
// Don't save something that isn't loaded lol
|
// Don't save something that isn't loaded lol
|
||||||
if($this->PackageLock == null)
|
if($this->PackageLock === null)
|
||||||
{
|
{
|
||||||
Console::outDebug('warning: PackageLock is null, not saving to disk');
|
Console::outDebug('warning: PackageLock is null, not saving to disk');
|
||||||
return;
|
return;
|
||||||
|
@ -144,7 +143,7 @@
|
||||||
}
|
}
|
||||||
catch(IOException $e)
|
catch(IOException $e)
|
||||||
{
|
{
|
||||||
throw new PackageLockException('Cannot save the package lock file to disk', $e);
|
throw new IOException('Cannot save the package lock file to disk', $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -155,7 +154,7 @@
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
throw new PackageLockException('Failed to synchronize symlinks', $e);
|
throw new IOException('Failed to synchronize symlinks', $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +162,8 @@
|
||||||
* Constructs the package lock file if it doesn't exist
|
* Constructs the package lock file if it doesn't exist
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws PackageLockException
|
* @throws AuthenticationException
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function constructLockFile(): void
|
public function constructLockFile(): void
|
||||||
{
|
{
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
{
|
{
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
unset($e);
|
unset($e);
|
||||||
$this->PackageLock = new PackageLock();
|
$this->PackageLock = new PackageLock();
|
||||||
|
@ -182,12 +182,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PackageLock|null
|
* @return PackageLock|null
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function getPackageLock(): ?PackageLock
|
public function getPackageLock(): ?PackageLock
|
||||||
{
|
{
|
||||||
if($this->PackageLock == null)
|
if($this->PackageLock === null)
|
||||||
|
{
|
||||||
$this->load();
|
$this->load();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->PackageLock;
|
return $this->PackageLock;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -43,11 +43,8 @@
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\NotSupportedException;
|
use ncc\Exceptions\NotSupportedException;
|
||||||
use ncc\Exceptions\PackageException;
|
use ncc\Exceptions\PackageException;
|
||||||
use ncc\Exceptions\PackageLockException;
|
|
||||||
use ncc\Exceptions\PackageNotFoundException;
|
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\RunnerExecutionException;
|
use ncc\Exceptions\RunnerExecutionException;
|
||||||
use ncc\Exceptions\SymlinkException;
|
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\VersionNotFoundException;
|
||||||
use ncc\Objects\DefinedRemoteSource;
|
use ncc\Objects\DefinedRemoteSource;
|
||||||
use ncc\Objects\InstallationPaths;
|
use ncc\Objects\InstallationPaths;
|
||||||
|
@ -84,7 +81,7 @@
|
||||||
private $package_lock_manager;
|
private $package_lock_manager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
@ -104,13 +101,10 @@
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws InstallationException
|
* @throws InstallationException
|
||||||
* @throws NotSupportedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageLockException
|
* @throws PackageException
|
||||||
* @throws PackageNotFoundException
|
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws RunnerExecutionException
|
* @throws RunnerExecutionException
|
||||||
* @throws SymlinkException
|
|
||||||
* @throws VersionNotFoundException
|
* @throws VersionNotFoundException
|
||||||
* @throws PackageException
|
|
||||||
*/
|
*/
|
||||||
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
|
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
|
||||||
{
|
{
|
||||||
|
@ -648,11 +642,8 @@
|
||||||
* @throws InstallationException
|
* @throws InstallationException
|
||||||
* @throws NotSupportedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageException
|
* @throws PackageException
|
||||||
* @throws PackageLockException
|
|
||||||
* @throws PackageNotFoundException
|
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws RunnerExecutionException
|
* @throws RunnerExecutionException
|
||||||
* @throws SymlinkException
|
|
||||||
* @throws VersionNotFoundException
|
* @throws VersionNotFoundException
|
||||||
*/
|
*/
|
||||||
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null, array $options=[]): void
|
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null, array $options=[]): void
|
||||||
|
@ -703,7 +694,7 @@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DependencySourceType::STATIC:
|
case DependencySourceType::STATIC:
|
||||||
throw new PackageNotFoundException('Static linking not possible, package ' . $dependency->name . ' is not installed');
|
throw new PackageException('Static linking not possible, package ' . $dependency->name . ' is not installed');
|
||||||
|
|
||||||
case DependencySourceType::REMOTE:
|
case DependencySourceType::REMOTE:
|
||||||
Console::outDebug('installing from remote source ' . $dependency->source);
|
Console::outDebug('installing from remote source ' . $dependency->source);
|
||||||
|
@ -717,7 +708,7 @@
|
||||||
}
|
}
|
||||||
elseif(!$dependency_met)
|
elseif(!$dependency_met)
|
||||||
{
|
{
|
||||||
throw new PackageNotFoundException(sprintf('Required dependency %s=%s is not installed', $dependency->name, $dependency->version));
|
throw new PackageException(sprintf('Required dependency %s=%s is not installed', $dependency->name, $dependency->version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,7 +717,7 @@
|
||||||
*
|
*
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @return PackageEntry|null
|
* @return PackageEntry|null
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function getPackage(string $package): ?PackageEntry
|
public function getPackage(string $package): ?PackageEntry
|
||||||
{
|
{
|
||||||
|
@ -740,8 +731,7 @@
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @param string $version
|
* @param string $version
|
||||||
* @return VersionEntry|null
|
* @return VersionEntry|null
|
||||||
* @throws VersionNotFoundException
|
* @throws IOException
|
||||||
* @throws PackageLockException
|
|
||||||
*/
|
*/
|
||||||
public function getPackageVersion(string $package, string $version): ?VersionEntry
|
public function getPackageVersion(string $package, string $version): ?VersionEntry
|
||||||
{
|
{
|
||||||
|
@ -754,9 +744,7 @@
|
||||||
*
|
*
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @return VersionEntry|null
|
* @return VersionEntry|null
|
||||||
* @throws VersionNotFoundException
|
* @throws IOException
|
||||||
* @throws PackageLockException
|
|
||||||
* @noinspection PhpUnused
|
|
||||||
*/
|
*/
|
||||||
public function getLatestVersion(string $package): ?VersionEntry
|
public function getLatestVersion(string $package): ?VersionEntry
|
||||||
{
|
{
|
||||||
|
@ -768,8 +756,7 @@
|
||||||
* Returns an array of all packages and their installed versions
|
* Returns an array of all packages and their installed versions
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
* @throws PackageLockException
|
|
||||||
*/
|
*/
|
||||||
public function getInstalledPackages(): array
|
public function getInstalledPackages(): array
|
||||||
{
|
{
|
||||||
|
@ -797,7 +784,7 @@
|
||||||
$package = $this->getPackage($exploded[0]);
|
$package = $this->getPackage($exploded[0]);
|
||||||
if($package === null)
|
if($package === null)
|
||||||
{
|
{
|
||||||
throw new PackageNotFoundException('Package ' . $exploded[0] . ' not found');
|
throw new PackageException('Package ' . $exploded[0] . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = $package->getVersion($exploded[1]);
|
$version = $package->getVersion($exploded[1]);
|
||||||
|
@ -836,7 +823,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
unset($e);
|
unset($e);
|
||||||
}
|
}
|
||||||
|
@ -884,10 +871,7 @@
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws PackageLockException
|
* @throws PackageException
|
||||||
* @throws PackageNotFoundException
|
|
||||||
* @throws SymlinkException
|
|
||||||
* @throws VersionNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function uninstallPackageVersion(string $package, string $version): void
|
public function uninstallPackageVersion(string $package, string $version): void
|
||||||
{
|
{
|
||||||
|
@ -899,7 +883,7 @@
|
||||||
$version_entry = $this->getPackageVersion($package, $version);
|
$version_entry = $this->getPackageVersion($package, $version);
|
||||||
if($version_entry === null)
|
if($version_entry === null)
|
||||||
{
|
{
|
||||||
throw new PackageNotFoundException(sprintf('The package %s=%s was not found', $package, $version));
|
throw new PackageException(sprintf('The package %s=%s was not found', $package, $version));
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::out(sprintf('Uninstalling %s=%s', $package, $version));
|
Console::out(sprintf('Uninstalling %s=%s', $package, $version));
|
||||||
|
@ -963,9 +947,8 @@
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
* @throws PackageNotFoundException
|
* @throws PackageException
|
||||||
* @throws VersionNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function uninstallPackage(string $package): void
|
public function uninstallPackage(string $package): void
|
||||||
{
|
{
|
||||||
|
@ -977,7 +960,7 @@
|
||||||
$package_entry = $this->getPackage($package);
|
$package_entry = $this->getPackage($package);
|
||||||
if($package_entry === null)
|
if($package_entry === null)
|
||||||
{
|
{
|
||||||
throw new PackageNotFoundException(sprintf('The package %s was not found', $package));
|
throw new PackageException(sprintf('The package %s was not found', $package));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($package_entry->getVersions() as $version)
|
foreach($package_entry->getVersions() as $version)
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\NotSupportedException;
|
use ncc\Exceptions\NotSupportedException;
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\ProjectAlreadyExistsException;
|
|
||||||
use ncc\Objects\ProjectConfiguration;
|
use ncc\Objects\ProjectConfiguration;
|
||||||
use ncc\Objects\ProjectConfiguration\Compiler;
|
use ncc\Objects\ProjectConfiguration\Compiler;
|
||||||
use ncc\ThirdParty\Symfony\Uid\Uuid;
|
use ncc\ThirdParty\Symfony\Uid\Uuid;
|
||||||
|
@ -105,8 +104,8 @@
|
||||||
* @param string|null $src
|
* @param string|null $src
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @throws ConfigurationException
|
* @throws ConfigurationException
|
||||||
|
* @throws IOException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws ProjectAlreadyExistsException
|
|
||||||
*/
|
*/
|
||||||
public function initializeProject(Compiler $compiler, string $name, string $package, ?string $src=null, array $options=[]): void
|
public function initializeProject(Compiler $compiler, string $name, string $package, ?string $src=null, array $options=[]): void
|
||||||
{
|
{
|
||||||
|
@ -123,7 +122,7 @@
|
||||||
|
|
||||||
if(file_exists($this->project_path . DIRECTORY_SEPARATOR . 'project.json'))
|
if(file_exists($this->project_path . DIRECTORY_SEPARATOR . 'project.json'))
|
||||||
{
|
{
|
||||||
throw new ProjectAlreadyExistsException('A project has already been initialized in \'' . $this->project_path . DIRECTORY_SEPARATOR . 'project.json' . '\'');
|
throw new IOException('A project has already been initialized in \'' . $this->project_path . DIRECTORY_SEPARATOR . 'project.json' . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->project_configuration = new ProjectConfiguration();
|
$this->project_configuration = new ProjectConfiguration();
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Enums\Scopes;
|
use ncc\Enums\Scopes;
|
||||||
use ncc\Exceptions\AuthenticationException;
|
use ncc\Exceptions\AuthenticationException;
|
||||||
use ncc\Exceptions\SymlinkException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Objects\SymlinkDictionary\SymlinkEntry;
|
use ncc\Objects\SymlinkDictionary\SymlinkEntry;
|
||||||
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
|
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
|
||||||
use ncc\Utilities\Console;
|
use ncc\Utilities\Console;
|
||||||
|
@ -85,7 +85,6 @@
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws SymlinkException
|
|
||||||
*/
|
*/
|
||||||
public function load(): void
|
public function load(): void
|
||||||
{
|
{
|
||||||
|
@ -130,7 +129,7 @@
|
||||||
* @param bool $throw_exception
|
* @param bool $throw_exception
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws SymlinkException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private function save(bool $throw_exception=true): void
|
private function save(bool $throw_exception=true): void
|
||||||
{
|
{
|
||||||
|
@ -154,7 +153,9 @@
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new SymlinkException(sprintf('failed to save symlink dictionary to %s', $this->SymlinkDictionaryPath), $e);
|
{
|
||||||
|
throw new IOException(sprintf('failed to save symlink dictionary to %s', $this->SymlinkDictionaryPath), $e);
|
||||||
|
}
|
||||||
|
|
||||||
Console::outWarning(sprintf('failed to save symlink dictionary to %s', $this->SymlinkDictionaryPath));
|
Console::outWarning(sprintf('failed to save symlink dictionary to %s', $this->SymlinkDictionaryPath));
|
||||||
}
|
}
|
||||||
|
@ -204,7 +205,7 @@
|
||||||
* @param string $unit
|
* @param string $unit
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws SymlinkException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function add(string $package, string $unit='main'): void
|
public function add(string $package, string $unit='main'): void
|
||||||
{
|
{
|
||||||
|
@ -232,7 +233,7 @@
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws SymlinkException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function remove(string $package): void
|
public function remove(string $package): void
|
||||||
{
|
{
|
||||||
|
@ -258,8 +259,10 @@
|
||||||
$symlink = self::$BinPath . DIRECTORY_SEPARATOR . $symlink_name;
|
$symlink = self::$BinPath . DIRECTORY_SEPARATOR . $symlink_name;
|
||||||
|
|
||||||
if($filesystem->exists($symlink))
|
if($filesystem->exists($symlink))
|
||||||
|
{
|
||||||
$filesystem->remove($symlink);
|
$filesystem->remove($symlink);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unset($this->SymlinkDictionary[$key]);
|
unset($this->SymlinkDictionary[$key]);
|
||||||
$this->save();
|
$this->save();
|
||||||
|
@ -267,7 +270,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new SymlinkException(sprintf('failed to remove package %s from the symlink dictionary', $package));
|
throw new IOException(sprintf('failed to remove package %s from the symlink dictionary', $package));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -276,7 +279,6 @@
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws SymlinkException
|
|
||||||
*/
|
*/
|
||||||
private function setAsRegistered(string $package): void
|
private function setAsRegistered(string $package): void
|
||||||
{
|
{
|
||||||
|
@ -297,7 +299,6 @@
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws SymlinkException
|
|
||||||
*/
|
*/
|
||||||
public function sync(): void
|
public function sync(): void
|
||||||
{
|
{
|
||||||
|
@ -328,7 +329,7 @@
|
||||||
{
|
{
|
||||||
$package_entry = $package_lock_manager->getPackageLock()->getPackage($entry->Package);
|
$package_entry = $package_lock_manager->getPackageLock()->getPackage($entry->Package);
|
||||||
|
|
||||||
if($package_entry == null)
|
if($package_entry === null)
|
||||||
{
|
{
|
||||||
Console::outWarning(sprintf('Package %s is not installed, skipping', $entry->Package));
|
Console::outWarning(sprintf('Package %s is not installed, skipping', $entry->Package));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -20,9 +23,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Objects;
|
namespace ncc\Objects;
|
||||||
|
|
||||||
use ncc\Exceptions\ConstantReadonlyException;
|
use ncc\Exceptions\IntegrityException;
|
||||||
use ncc\Utilities\Resolver;
|
use ncc\Utilities\Resolver;
|
||||||
|
|
||||||
class Constant
|
class Constant
|
||||||
|
@ -32,35 +35,35 @@ namespace ncc\Objects;
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $Hash;
|
private $hash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The package that manages this constant
|
* The package that manages this constant
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $Scope;
|
private $scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the constant
|
* The name of the constant
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $Name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value of the constant
|
* The value of the constant
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $Value;
|
private $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the constant is readonly or not
|
* Indicates if the constant is readonly or not
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $Readonly;
|
private $readonly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Constructor
|
* Public Constructor
|
||||||
|
@ -72,11 +75,11 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function __construct(string $scope, string $name, string $value, bool $readonly=false)
|
public function __construct(string $scope, string $name, string $value, bool $readonly=false)
|
||||||
{
|
{
|
||||||
$this->Scope = $scope;
|
$this->scope = $scope;
|
||||||
$this->Name = $name;
|
$this->name = $name;
|
||||||
$this->Value = $value;
|
$this->value = $value;
|
||||||
$this->Readonly = $readonly;
|
$this->readonly = $readonly;
|
||||||
$this->Hash = Resolver::resolveConstantHash($this->Scope, $this->Name);
|
$this->hash = Resolver::resolveConstantHash($this->scope, $this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +89,7 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return $this->Value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,7 +97,7 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function getValue(): string
|
public function getValue(): string
|
||||||
{
|
{
|
||||||
return $this->Value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,23 +107,23 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function getFullName(): string
|
public function getFullName(): string
|
||||||
{
|
{
|
||||||
return Resolver::resolveFullConstantName($this->Scope, $this->Name);
|
return Resolver::resolveFullConstantName($this->scope, $this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param bool $readonly
|
* @param bool $readonly
|
||||||
* @throws ConstantReadonlyException
|
* @throws IntegrityException
|
||||||
*/
|
*/
|
||||||
public function setValue(string $value, bool $readonly=false): void
|
public function setValue(string $value, bool $readonly=false): void
|
||||||
{
|
{
|
||||||
if($this->Readonly)
|
if($this->readonly)
|
||||||
{
|
{
|
||||||
throw new ConstantReadonlyException('Cannot set value to the constant \'' . $this->getFullName() . '\', constant is readonly');
|
throw new IntegrityException('Cannot set value to the constant \'' . $this->getFullName() . '\', constant is readonly');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Value = $value;
|
$this->value = $value;
|
||||||
$this->Readonly = $readonly;
|
$this->readonly = $readonly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +131,7 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function isReadonly(): bool
|
public function isReadonly(): bool
|
||||||
{
|
{
|
||||||
return $this->Readonly;
|
return $this->readonly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +139,7 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function getHash(): string
|
public function getHash(): string
|
||||||
{
|
{
|
||||||
return $this->Hash;
|
return $this->hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +147,7 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function getScope(): string
|
public function getScope(): string
|
||||||
{
|
{
|
||||||
return $this->Scope;
|
return $this->scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,6 +155,6 @@ namespace ncc\Objects;
|
||||||
*/
|
*/
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return $this->Name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
use ncc\Enums\Scopes;
|
use ncc\Enums\Scopes;
|
||||||
use ncc\Enums\Versions;
|
use ncc\Enums\Versions;
|
||||||
use ncc\Exceptions\ConfigurationException;
|
use ncc\Exceptions\ConfigurationException;
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Objects\Package;
|
use ncc\Objects\Package;
|
||||||
use ncc\Objects\ProjectConfiguration\UpdateSource;
|
use ncc\Objects\ProjectConfiguration\UpdateSource;
|
||||||
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
* @param string $version
|
* @param string $version
|
||||||
* @param bool $throw_exception
|
* @param bool $throw_exception
|
||||||
* @return VersionEntry|null
|
* @return VersionEntry|null
|
||||||
* @throws VersionNotFoundException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function getVersion(string $version, bool $throw_exception=false): ?VersionEntry
|
public function getVersion(string $version, bool $throw_exception=false): ?VersionEntry
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
throw new VersionNotFoundException('The version entry is not found');
|
throw new IOException(sprintf('Version %s of %s is not installed', $version, $this->Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
$this->removeVersion($package->assembly->version);
|
$this->removeVersion($package->assembly->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (VersionNotFoundException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
unset($e);
|
unset($e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,11 @@
|
||||||
use ncc\Enums\CompilerExtensions;
|
use ncc\Enums\CompilerExtensions;
|
||||||
use ncc\Enums\Versions;
|
use ncc\Enums\Versions;
|
||||||
use ncc\Classes\PhpExtension\PhpRuntime;
|
use ncc\Classes\PhpExtension\PhpRuntime;
|
||||||
use ncc\Exceptions\ConstantReadonlyException;
|
use ncc\Exceptions\ConfigurationException;
|
||||||
use ncc\Exceptions\ImportException;
|
use ncc\Exceptions\ImportException;
|
||||||
use ncc\Exceptions\InvalidConstantNameException;
|
use ncc\Exceptions\IntegrityException;
|
||||||
use ncc\Exceptions\PackageLockException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\PackageNotFoundException;
|
use ncc\Exceptions\PackageException;
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
|
||||||
use ncc\Managers\PackageManager;
|
use ncc\Managers\PackageManager;
|
||||||
use ncc\Objects\PackageLock\VersionEntry;
|
use ncc\Objects\PackageLock\VersionEntry;
|
||||||
use ncc\Objects\ProjectConfiguration\Dependency;
|
use ncc\Objects\ProjectConfiguration\Dependency;
|
||||||
|
@ -57,7 +56,7 @@
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @param string $version
|
* @param string $version
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws PackageLockException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static function isImported(string $package, string $version=Versions::LATEST): bool
|
private static function isImported(string $package, string $version=Versions::LATEST): bool
|
||||||
{
|
{
|
||||||
|
@ -90,6 +89,7 @@
|
||||||
* @param string $version
|
* @param string $version
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws IOException
|
||||||
* @throws ImportException
|
* @throws ImportException
|
||||||
*/
|
*/
|
||||||
public static function import(string $package, string $version=Versions::LATEST, array $options=[]): void
|
public static function import(string $package, string $version=Versions::LATEST, array $options=[]): void
|
||||||
|
@ -98,10 +98,11 @@
|
||||||
{
|
{
|
||||||
$package_entry = self::getPackageManager()->getPackage($package);
|
$package_entry = self::getPackageManager()->getPackage($package);
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
throw new ImportException(sprintf('Failed to import package "%s" due to a package lock exception: %s', $package, $e->getMessage()), $e);
|
throw new ImportException(sprintf('Failed to import package "%s" due to a package lock exception: %s', $package, $e->getMessage()), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($package_entry === null)
|
if($package_entry === null)
|
||||||
{
|
{
|
||||||
throw new ImportException(sprintf("Package '%s' not found", $package));
|
throw new ImportException(sprintf("Package '%s' not found", $package));
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package));
|
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (VersionNotFoundException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package), $e);
|
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package), $e);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +135,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (IOException $e)
|
||||||
{
|
{
|
||||||
throw new ImportException(sprintf('Failed to check if package %s is imported', $package), $e);
|
throw new ImportException(sprintf('Failed to check if package %s is imported', $package), $e);
|
||||||
}
|
}
|
||||||
|
@ -174,8 +175,9 @@
|
||||||
*
|
*
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @return string
|
* @return string
|
||||||
* @throws PackageLockException
|
* @throws ConfigurationException
|
||||||
* @throws PackageNotFoundException
|
* @throws IOException
|
||||||
|
* @throws PackageException
|
||||||
*/
|
*/
|
||||||
public static function getDataPath(string $package): string
|
public static function getDataPath(string $package): string
|
||||||
{
|
{
|
||||||
|
@ -183,7 +185,7 @@
|
||||||
|
|
||||||
if($package === null)
|
if($package === null)
|
||||||
{
|
{
|
||||||
throw new PackageNotFoundException('Package not found (null entry error, possible bug)');
|
throw new PackageException('Package not found (null entry error, possible bug)');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $package->getDataPath();
|
return $package->getDataPath();
|
||||||
|
@ -231,8 +233,7 @@
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConstantReadonlyException
|
* @throws IntegrityException
|
||||||
* @throws InvalidConstantNameException
|
|
||||||
*/
|
*/
|
||||||
public static function setConstant(string $package, string $name, string $value): void
|
public static function setConstant(string $package, string $name, string $value): void
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
namespace ncc\Runtime;
|
namespace ncc\Runtime;
|
||||||
|
|
||||||
use ncc\Exceptions\ConstantReadonlyException;
|
use InvalidArgumentException;
|
||||||
use ncc\Exceptions\InvalidConstantNameException;
|
use ncc\Exceptions\IntegrityException;
|
||||||
use ncc\Objects\Constant;
|
use ncc\Objects\Constant;
|
||||||
use ncc\Utilities\Resolver;
|
use ncc\Utilities\Resolver;
|
||||||
use ncc\Utilities\Validate;
|
use ncc\Utilities\Validate;
|
||||||
|
@ -47,13 +47,14 @@
|
||||||
* @param string $value The value of the constant
|
* @param string $value The value of the constant
|
||||||
* @param bool $readonly Indicates if the constant cannot be changed with the registerConstant function once it's registered
|
* @param bool $readonly Indicates if the constant cannot be changed with the registerConstant function once it's registered
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConstantReadonlyException
|
* @throws IntegrityException
|
||||||
* @throws InvalidConstantNameException
|
|
||||||
*/
|
*/
|
||||||
public static function register(string $scope, string $name, string $value, bool $readonly=false): void
|
public static function register(string $scope, string $name, string $value, bool $readonly=false): void
|
||||||
{
|
{
|
||||||
if(!Validate::constantName($name))
|
if(!Validate::constantName($name))
|
||||||
throw new InvalidConstantNameException('The name specified is not valid for a constant name');
|
{
|
||||||
|
throw new InvalidArgumentException(sprintf('The name \'%s\' is not a valid constant name', $name));
|
||||||
|
}
|
||||||
|
|
||||||
$constant_hash = Resolver::resolveConstantHash($scope, $name);
|
$constant_hash = Resolver::resolveConstantHash($scope, $name);
|
||||||
|
|
||||||
|
@ -72,18 +73,20 @@
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConstantReadonlyException
|
* @throws IntegrityException
|
||||||
*/
|
*/
|
||||||
public static function delete(string $scope, string $name): void
|
public static function delete(string $scope, string $name): void
|
||||||
{
|
{
|
||||||
if(!Validate::constantName($name))
|
if(!Validate::constantName($name))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$constant_hash = Resolver::resolveConstantHash($scope, $name);
|
$constant_hash = Resolver::resolveConstantHash($scope, $name);
|
||||||
|
|
||||||
if(isset(self::$Constants[$constant_hash]) && self::$Constants[$constant_hash]->isReadonly())
|
if(isset(self::$Constants[$constant_hash]) && self::$Constants[$constant_hash]->isReadonly())
|
||||||
{
|
{
|
||||||
throw new ConstantReadonlyException('Cannot delete the constant \'' . self::$Constants[$constant_hash]->getFullName() . '\', constant is readonly');
|
throw new IntegrityException('Cannot delete the constant \'' . self::$Constants[$constant_hash]->getFullName() . '\', constant is readonly');
|
||||||
}
|
}
|
||||||
|
|
||||||
unset(self::$Constants[$constant_hash]);
|
unset(self::$Constants[$constant_hash]);
|
||||||
|
@ -99,12 +102,16 @@
|
||||||
public static function get(string $scope, string $name): ?string
|
public static function get(string $scope, string $name): ?string
|
||||||
{
|
{
|
||||||
if(!Validate::constantName($name))
|
if(!Validate::constantName($name))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$constant_hash = Resolver::resolveConstantHash($scope, $name);
|
$constant_hash = Resolver::resolveConstantHash($scope, $name);
|
||||||
|
|
||||||
if(isset(self::$Constants[$constant_hash]))
|
if(isset(self::$Constants[$constant_hash]))
|
||||||
|
{
|
||||||
return self::$Constants[$constant_hash]->getValue();
|
return self::$Constants[$constant_hash]->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue