self::UNSUPPORTED_EXTENSION_VERSION,
This commit is contained in:
parent
57305c8b52
commit
14541123c0
24 changed files with 236 additions and 435 deletions
|
@ -121,6 +121,11 @@ features.
|
||||||
- Removed unused exception `GitCheckoutException` in `\ncc\Exceptions` in favor of `GitException`
|
- Removed unused exception `GitCheckoutException` in `\ncc\Exceptions` in favor of `GitException`
|
||||||
- Removed unused exception `GithubServiceException` in `\ncc\Exceptions` in favor of `GitException`
|
- Removed unused exception `GithubServiceException` in `\ncc\Exceptions` in favor of `GitException`
|
||||||
- Removed unused exception `GitTagsException` in `\ncc\Exceptions` in favor of `GitException`
|
- Removed unused exception `GitTagsException` in `\ncc\Exceptions` in favor of `GitException`
|
||||||
|
- Removed unused exception `GitlabServiceException` in `\ncc\Exceptions` in favor of `GitException`
|
||||||
|
- Removed unused exception `UnsupportedArchiveException` in `\ncc\Exceptions` in favor of `ArchiveException`
|
||||||
|
- Removed unused exception `NotImplementedException` in `\ncc\Exceptions` in favor of `NotSupportedException`
|
||||||
|
- Removed unused exception `UnsupportedCompilerExtensionException` in `\ncc\Exceptions` in favor of `NotSupportedException`
|
||||||
|
- Removed unused exception `UnsupportedExtensionVersionException` in `\ncc\Exceptions` (not used)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,17 +55,17 @@ GitException
|
||||||
* GIT_CLONE_EXCEPTION
|
* GIT_CLONE_EXCEPTION
|
||||||
* GIT_CHECKOUT_EXCEPTION
|
* GIT_CHECKOUT_EXCEPTION
|
||||||
* GITHUB_SERVICE_EXCEPTION
|
* GITHUB_SERVICE_EXCEPTION
|
||||||
GITLAB_SERVICE_EXCEPTION
|
* GITLAB_SERVICE_EXCEPTION
|
||||||
* GIT_TAGS_EXCEPTION
|
* GIT_TAGS_EXCEPTION
|
||||||
|
|
||||||
ArchiveException
|
ArchiveException
|
||||||
UNSUPPORTED_ARCHIVE
|
* UNSUPPORTED_ARCHIVE
|
||||||
ARCHIVE_EXCEPTION
|
* ARCHIVE_EXCEPTION
|
||||||
|
|
||||||
NotSupportedException
|
NotSupportedException
|
||||||
NOT_IMPLEMENTED
|
* NOT_IMPLEMENTED
|
||||||
UNSUPPORTED_COMPILER_EXTENSION
|
* UNSUPPORTED_COMPILER_EXTENSION
|
||||||
UNSUPPORTED_EXTENSION_VERSION
|
* UNSUPPORTED_EXTENSION_VERSION
|
||||||
UNSUPPORTED_COMPONENT_TYPE
|
UNSUPPORTED_COMPONENT_TYPE
|
||||||
NOT_SUPPORTED_EXCEPTION
|
NOT_SUPPORTED_EXCEPTION
|
||||||
UNSUPPORTED_PROJECT_TYPE
|
UNSUPPORTED_PROJECT_TYPE
|
||||||
|
|
|
@ -40,14 +40,12 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
use ncc\Exceptions\ComposerNotAvailableException;
|
use ncc\Exceptions\ComposerNotAvailableException;
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\InternalComposerNotAvailableException;
|
use ncc\Exceptions\InternalComposerNotAvailableException;
|
||||||
use ncc\Exceptions\InvalidScopeException;
|
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\PackageNotFoundException;
|
use ncc\Exceptions\PackageNotFoundException;
|
||||||
use ncc\Exceptions\PackagePreparationFailedException;
|
use ncc\Exceptions\PackagePreparationFailedException;
|
||||||
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
|
||||||
use ncc\Exceptions\UserAbortedOperationException;
|
use ncc\Exceptions\UserAbortedOperationException;
|
||||||
use ncc\Interfaces\ServiceSourceInterface;
|
use ncc\Interfaces\ServiceSourceInterface;
|
||||||
use ncc\Managers\ProjectManager;
|
use ncc\Managers\ProjectManager;
|
||||||
|
@ -89,14 +87,12 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
* @throws ComposerNotAvailableException
|
* @throws ComposerNotAvailableException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws InternalComposerNotAvailableException
|
* @throws InternalComposerNotAvailableException
|
||||||
* @throws InvalidScopeException
|
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws PackageNotFoundException
|
* @throws PackageNotFoundException
|
||||||
* @throws PackagePreparationFailedException
|
* @throws PackagePreparationFailedException
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws ProjectConfigurationNotFoundException
|
* @throws ProjectConfigurationNotFoundException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws UserAbortedOperationException
|
* @throws UserAbortedOperationException
|
||||||
*/
|
*/
|
||||||
public static function fetch(RemotePackageInput $packageInput): string
|
public static function fetch(RemotePackageInput $packageInput): string
|
||||||
|
@ -136,7 +132,6 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
* @throws PackagePreparationFailedException
|
* @throws PackagePreparationFailedException
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws ProjectConfigurationNotFoundException
|
* @throws ProjectConfigurationNotFoundException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws UserAbortedOperationException
|
* @throws UserAbortedOperationException
|
||||||
*/
|
*/
|
||||||
public static function fromLocal(string $path): string
|
public static function fromLocal(string $path): string
|
||||||
|
@ -208,7 +203,6 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
* @throws PackagePreparationFailedException
|
* @throws PackagePreparationFailedException
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws ProjectConfigurationNotFoundException
|
* @throws ProjectConfigurationNotFoundException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
*/
|
*/
|
||||||
private static function compilePackages(string $composer_lock_path): array
|
private static function compilePackages(string $composer_lock_path): array
|
||||||
{
|
{
|
||||||
|
@ -529,21 +523,19 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
* @param string $package
|
* @param string $package
|
||||||
* @param string|null $version
|
* @param string|null $version
|
||||||
* @return string
|
* @return string
|
||||||
* @throws AccessDeniedException
|
|
||||||
* @throws ComposerDisabledException
|
* @throws ComposerDisabledException
|
||||||
* @throws ComposerException
|
* @throws ComposerException
|
||||||
* @throws ComposerNotAvailableException
|
* @throws ComposerNotAvailableException
|
||||||
* @throws PathNotFoundException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws InternalComposerNotAvailableException
|
* @throws InternalComposerNotAvailableException
|
||||||
* @throws InvalidScopeException
|
* @throws PathNotFoundException
|
||||||
* @throws UserAbortedOperationException
|
* @throws UserAbortedOperationException
|
||||||
*/
|
*/
|
||||||
private static function require(string $vendor, string $package, ?string $version = null): string
|
private static function require(string $vendor, string $package, ?string $version = null): string
|
||||||
{
|
{
|
||||||
if (Resolver::resolveScope() !== Scopes::SYSTEM)
|
if (Resolver::resolveScope() !== Scopes::SYSTEM)
|
||||||
{
|
{
|
||||||
throw new AccessDeniedException('Insufficient permissions to require');
|
throw new \RuntimeException('Cannot require a package with insufficient permissions');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($version === null)
|
if ($version === null)
|
||||||
|
@ -693,10 +685,10 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
* @param array $version_map
|
* @param array $version_map
|
||||||
* @param mixed $composer_package
|
* @param mixed $composer_package
|
||||||
* @return ProjectConfiguration
|
* @return ProjectConfiguration
|
||||||
* @throws AccessDeniedException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws PackagePreparationFailedException
|
* @throws PackagePreparationFailedException
|
||||||
|
* @throws PathNotFoundException
|
||||||
*/
|
*/
|
||||||
private static function convertProject(string $package_path, array $version_map, ?ComposerJson $composer_package=null): ProjectConfiguration
|
private static function convertProject(string $package_path, array $version_map, ?ComposerJson $composer_package=null): ProjectConfiguration
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
use ncc\Classes\HttpClient;
|
use ncc\Classes\HttpClient;
|
||||||
use ncc\Exceptions\AuthenticationException;
|
use ncc\Exceptions\AuthenticationException;
|
||||||
use ncc\Exceptions\GitException;
|
use ncc\Exceptions\GitException;
|
||||||
use ncc\Exceptions\GitlabServiceException;
|
|
||||||
use ncc\Exceptions\HttpException;
|
use ncc\Exceptions\HttpException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\VersionNotFoundException;
|
||||||
|
@ -51,7 +50,6 @@
|
||||||
* @return RepositoryQueryResults
|
* @return RepositoryQueryResults
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitException
|
* @throws GitException
|
||||||
* @throws GitlabServiceException
|
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
*/
|
*/
|
||||||
|
@ -78,20 +76,19 @@
|
||||||
/**
|
/**
|
||||||
* Returns the download URL of the requested version of the package.
|
* Returns the download URL of the requested version of the package.
|
||||||
*
|
*
|
||||||
* @param RemotePackageInput $packageInput
|
* @param RemotePackageInput $package_input
|
||||||
* @param DefinedRemoteSource $definedRemoteSource
|
* @param DefinedRemoteSource $defined_remote_source
|
||||||
* @param Entry|null $entry
|
* @param Entry|null $entry
|
||||||
* @return RepositoryQueryResults
|
* @return RepositoryQueryResults
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitException
|
* @throws GitException
|
||||||
* @throws GitlabServiceException
|
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws VersionNotFoundException
|
* @throws VersionNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function getRelease(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
|
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults
|
||||||
{
|
{
|
||||||
return self::processReleases($packageInput, $definedRemoteSource, $entry);
|
return self::processReleases($package_input, $defined_remote_source, $entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +98,6 @@
|
||||||
* @return RepositoryQueryResults
|
* @return RepositoryQueryResults
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitException
|
* @throws GitException
|
||||||
* @throws GitlabServiceException
|
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws VersionNotFoundException
|
* @throws VersionNotFoundException
|
||||||
|
@ -120,7 +116,6 @@
|
||||||
* @return array
|
* @return array
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitException
|
* @throws GitException
|
||||||
* @throws GitlabServiceException
|
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
*/
|
*/
|
||||||
|
@ -195,7 +190,6 @@
|
||||||
* @throws GitException
|
* @throws GitException
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws GitlabServiceException
|
|
||||||
*/
|
*/
|
||||||
private static function getJsonResponse(HttpRequest $httpRequest, ?Entry $entry): array
|
private static function getJsonResponse(HttpRequest $httpRequest, ?Entry $entry): array
|
||||||
{
|
{
|
||||||
|
@ -221,7 +215,6 @@
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitException
|
* @throws GitException
|
||||||
* @throws GitlabServiceException
|
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws VersionNotFoundException
|
* @throws VersionNotFoundException
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
<?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
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
* 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
|
* 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
|
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
* conditions:
|
* conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||||
* of the Software.
|
* of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
* 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
|
* 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
|
* 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
|
* 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
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Classes\GitlabExtension;
|
namespace ncc\Classes\GitlabExtension;
|
||||||
|
|
||||||
use ncc\Enums\Versions;
|
use ncc\Enums\Versions;
|
||||||
use ncc\Classes\HttpClient;
|
use ncc\Classes\HttpClient;
|
||||||
use ncc\Exceptions\AuthenticationException;
|
use ncc\Exceptions\AuthenticationException;
|
||||||
use ncc\Exceptions\GitlabServiceException;
|
use ncc\Exceptions\GitException;
|
||||||
use ncc\Exceptions\HttpException;
|
use ncc\Exceptions\HttpException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\NotSupportedException;
|
use ncc\Exceptions\NotSupportedException;
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\ResourceNotFoundException;
|
||||||
use ncc\Interfaces\RepositorySourceInterface;
|
use ncc\Interfaces\RepositorySourceInterface;
|
||||||
use ncc\Objects\DefinedRemoteSource;
|
use ncc\Objects\DefinedRemoteSource;
|
||||||
use ncc\Objects\HttpRequest;
|
use ncc\Objects\HttpRequest;
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
* @param Entry|null $entry
|
* @param Entry|null $entry
|
||||||
* @return RepositoryQueryResults
|
* @return RepositoryQueryResults
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitlabServiceException
|
* @throws GitException
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
*/
|
*/
|
||||||
|
@ -69,8 +69,7 @@
|
||||||
|
|
||||||
if($response->StatusCode !== 200)
|
if($response->StatusCode !== 200)
|
||||||
{
|
{
|
||||||
throw new GitlabServiceException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
|
throw new GitException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
||||||
|
@ -88,27 +87,27 @@
|
||||||
/**
|
/**
|
||||||
* Returns the download URL of the requested version of the package.
|
* Returns the download URL of the requested version of the package.
|
||||||
*
|
*
|
||||||
* @param RemotePackageInput $packageInput
|
* @param RemotePackageInput $package_input
|
||||||
* @param DefinedRemoteSource $definedRemoteSource
|
* @param DefinedRemoteSource $defined_remote_source
|
||||||
* @param Entry|null $entry
|
* @param Entry|null $entry
|
||||||
* @return RepositoryQueryResults
|
* @return RepositoryQueryResults
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitlabServiceException
|
* @throws GitException
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws VersionNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function getRelease(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
|
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults
|
||||||
{
|
{
|
||||||
$releases = self::getReleases($packageInput->vendor, $packageInput->package, $definedRemoteSource, $entry);
|
$releases = self::getReleases($package_input->vendor, $package_input->package, $defined_remote_source, $entry);
|
||||||
|
|
||||||
if(count($releases) === 0)
|
if(count($releases) === 0)
|
||||||
{
|
{
|
||||||
throw new VersionNotFoundException('No releases found for the given repository.');
|
throw new ResourceNotFoundException(sprintf('No releases found for the repository %s/%s (selected version: %s)', $package_input->vendor, $package_input->package, $package_input->version));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query the latest package only
|
// Query the latest package only
|
||||||
if($packageInput->version === Versions::LATEST)
|
if($package_input->version === Versions::LATEST)
|
||||||
{
|
{
|
||||||
$latest_version = null;
|
$latest_version = null;
|
||||||
foreach($releases as $release)
|
foreach($releases as $release)
|
||||||
|
@ -129,7 +128,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query a specific version
|
// Query a specific version
|
||||||
if(!isset($releases[$packageInput->version]))
|
if(!isset($releases[$package_input->version]))
|
||||||
{
|
{
|
||||||
// Find the closest thing to the requested version
|
// Find the closest thing to the requested version
|
||||||
$selected_version = null;
|
$selected_version = null;
|
||||||
|
@ -141,7 +140,7 @@
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(VersionComparator::compareVersion($version, $packageInput->version) === 1)
|
if(VersionComparator::compareVersion($version, $package_input->version) === 1)
|
||||||
{
|
{
|
||||||
$selected_version = $version;
|
$selected_version = $version;
|
||||||
}
|
}
|
||||||
|
@ -149,18 +148,17 @@
|
||||||
|
|
||||||
if($selected_version === null)
|
if($selected_version === null)
|
||||||
{
|
{
|
||||||
throw new VersionNotFoundException('No releases found for the given repository.');
|
throw new ResourceNotFoundException(sprintf('Could not find a release for %s/%s with the version %s', $package_input->vendor, $package_input->package, $package_input->version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$selected_version = $packageInput->version;
|
$selected_version = $package_input->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($releases[$selected_version]))
|
if(!isset($releases[$selected_version]))
|
||||||
{
|
{
|
||||||
throw new VersionNotFoundException(sprintf('No releases found for the given repository. (Selected version: %s)', $selected_version));
|
throw new ResourceNotFoundException(sprintf('Could not find a release for %s/%s with the version %s', $package_input->vendor, $package_input->package, $package_input->version));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $releases[$selected_version];
|
return $releases[$selected_version];
|
||||||
|
@ -187,7 +185,7 @@
|
||||||
* @param Entry|null $entry
|
* @param Entry|null $entry
|
||||||
* @return array
|
* @return array
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitlabServiceException
|
* @throws GitException
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
*/
|
*/
|
||||||
|
@ -207,7 +205,7 @@
|
||||||
|
|
||||||
if($response->StatusCode !== 200)
|
if($response->StatusCode !== 200)
|
||||||
{
|
{
|
||||||
throw new GitlabServiceException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
|
throw new GitException(sprintf('Failed to fetch releases for repository %s/%s. Status code: %s', $owner, $repository, $response->StatusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
use ncc\Exceptions\BuildException;
|
use ncc\Exceptions\BuildException;
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
|
use ncc\Exceptions\NotSupportedException;
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
||||||
use ncc\Exceptions\RunnerExecutionException;
|
use ncc\Exceptions\RunnerExecutionException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
|
||||||
use ncc\Exceptions\UnsupportedProjectTypeException;
|
use ncc\Exceptions\UnsupportedProjectTypeException;
|
||||||
use ncc\Interfaces\CompilerInterface;
|
use ncc\Interfaces\CompilerInterface;
|
||||||
use ncc\Managers\ProjectManager;
|
use ncc\Managers\ProjectManager;
|
||||||
|
@ -65,9 +65,9 @@
|
||||||
* @throws BuildException
|
* @throws BuildException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws ProjectConfigurationNotFoundException
|
* @throws NotSupportedException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
|
* @throws ProjectConfigurationNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function compile(ProjectManager $manager, string $build_configuration=BuildConfigurationValues::DEFAULT): string
|
public static function compile(ProjectManager $manager, string $build_configuration=BuildConfigurationValues::DEFAULT): string
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $configuration->project->compiler->extension . '\' is not supported');
|
throw new NotSupportedException('The compiler extension \'' . $configuration->project->compiler->extension . '\' is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->name;
|
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->name;
|
||||||
|
|
|
@ -1,32 +1,26 @@
|
||||||
<?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
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
* 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
|
* 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
|
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
* conditions:
|
* conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||||
* of the Software.
|
* of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
* 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
|
* 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
|
* 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
|
* 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
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Enums;
|
namespace ncc\Enums;
|
||||||
|
|
||||||
use ncc\Exceptions\GitException;
|
|
||||||
use ncc\Exceptions\InvalidDependencyConfiguration;
|
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
|
||||||
use ncc\Exceptions\SymlinkException;
|
|
||||||
use ncc\Exceptions\UnsupportedArchiveException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
|
@ -104,16 +98,6 @@ namespace ncc\Enums;
|
||||||
*/
|
*/
|
||||||
public const NO_UNITS_FOUND = -1715;
|
public const NO_UNITS_FOUND = -1715;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UnsupportedPackageException
|
|
||||||
*/
|
|
||||||
public const UNSUPPORTED_PACKAGE = -1716;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see NotImplementedException
|
|
||||||
*/
|
|
||||||
public const NOT_IMPLEMENTED = -1717;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see InvalidPackageException
|
* @see InvalidPackageException
|
||||||
*/
|
*/
|
||||||
|
@ -139,11 +123,6 @@ namespace ncc\Enums;
|
||||||
*/
|
*/
|
||||||
public const INVALID_PROJECT_BUILD_CONFIGURATION = -1722;
|
public const INVALID_PROJECT_BUILD_CONFIGURATION = -1722;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UnsupportedCompilerExtensionException
|
|
||||||
*/
|
|
||||||
public const UNSUPPORTED_COMPILER_EXTENSION = -1723;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see InvalidPropertyValueException
|
* @see InvalidPropertyValueException
|
||||||
*/
|
*/
|
||||||
|
@ -154,11 +133,6 @@ namespace ncc\Enums;
|
||||||
*/
|
*/
|
||||||
public const INVALID_VERSION_CONFIGURATION = -1725;
|
public const INVALID_VERSION_CONFIGURATION = -1725;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UnsupportedExtensionVersionException
|
|
||||||
*/
|
|
||||||
public const UNSUPPORTED_EXTENSION_VERSION = -1726;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BuildException
|
* @see BuildException
|
||||||
*/
|
*/
|
||||||
|
@ -284,11 +258,6 @@ namespace ncc\Enums;
|
||||||
*/
|
*/
|
||||||
public const UNSUPPORTED_REMOTE_SOURCE_TYPE = -1753;
|
public const UNSUPPORTED_REMOTE_SOURCE_TYPE = -1753;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GitlabServiceException
|
|
||||||
*/
|
|
||||||
public const GITLAB_SERVICE_EXCEPTION = -1756;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ImportException
|
* @see ImportException
|
||||||
*/
|
*/
|
||||||
|
@ -309,11 +278,6 @@ namespace ncc\Enums;
|
||||||
*/
|
*/
|
||||||
public const UNSUPPORTED_PROJECT_TYPE = -1762;
|
public const UNSUPPORTED_PROJECT_TYPE = -1762;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UnsupportedArchiveException
|
|
||||||
*/
|
|
||||||
public const UNSUPPORTED_ARCHIVE = -1763;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ArchiveException
|
* @see ArchiveException
|
||||||
*/
|
*/
|
||||||
|
@ -349,6 +313,11 @@ namespace ncc\Enums;
|
||||||
*/
|
*/
|
||||||
public const GIT_EXCEPTION = -1770;
|
public const GIT_EXCEPTION = -1770;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceNotFoundException
|
||||||
|
*/
|
||||||
|
public const RESOURCE_NOT_FOUND = -1771;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the exception codes from NCC
|
* All the exception codes from NCC
|
||||||
*/
|
*/
|
||||||
|
@ -367,17 +336,13 @@ namespace ncc\Enums;
|
||||||
self::PROJECT_ALREADY_EXISTS,
|
self::PROJECT_ALREADY_EXISTS,
|
||||||
self::AUTOLOAD_GENERATOR,
|
self::AUTOLOAD_GENERATOR,
|
||||||
self::NO_UNITS_FOUND,
|
self::NO_UNITS_FOUND,
|
||||||
self::UNSUPPORTED_PACKAGE,
|
|
||||||
self::NOT_IMPLEMENTED,
|
|
||||||
self::INVALID_PACKAGE,
|
self::INVALID_PACKAGE,
|
||||||
self::INVALID_CONSTANT_NAME,
|
self::INVALID_CONSTANT_NAME,
|
||||||
self::PACKAGE_PREPARATION_FAILED,
|
self::PACKAGE_PREPARATION_FAILED,
|
||||||
self::BUILD_CONFIGURATION_NOT_FOUND,
|
self::BUILD_CONFIGURATION_NOT_FOUND,
|
||||||
self::INVALID_PROJECT_BUILD_CONFIGURATION,
|
self::INVALID_PROJECT_BUILD_CONFIGURATION,
|
||||||
self::UNSUPPORTED_COMPILER_EXTENSION,
|
|
||||||
self::INVALID_PROPERTY_VALUE,
|
self::INVALID_PROPERTY_VALUE,
|
||||||
self::INVALID_VERSION_CONFIGURATION,
|
self::INVALID_VERSION_CONFIGURATION,
|
||||||
self::UNSUPPORTED_EXTENSION_VERSION,
|
|
||||||
self::BUILD_EXCEPTION,
|
self::BUILD_EXCEPTION,
|
||||||
self::PACKAGE_PARSING_EXCEPTION,
|
self::PACKAGE_PARSING_EXCEPTION,
|
||||||
self::PACKAGE_LOCK_EXCEPTION,
|
self::PACKAGE_LOCK_EXCEPTION,
|
||||||
|
@ -402,17 +367,16 @@ namespace ncc\Enums;
|
||||||
self::MISSING_DEPENDENCY,
|
self::MISSING_DEPENDENCY,
|
||||||
self::HTTP_EXCEPTION,
|
self::HTTP_EXCEPTION,
|
||||||
self::UNSUPPORTED_REMOTE_SOURCE_TYPE,
|
self::UNSUPPORTED_REMOTE_SOURCE_TYPE,
|
||||||
self::GITLAB_SERVICE_EXCEPTION,
|
|
||||||
self::AUTHENTICATION_EXCEPTION,
|
self::AUTHENTICATION_EXCEPTION,
|
||||||
self::NOT_SUPPORTED_EXCEPTION,
|
self::NOT_SUPPORTED_EXCEPTION,
|
||||||
self::UNSUPPORTED_PROJECT_TYPE,
|
self::UNSUPPORTED_PROJECT_TYPE,
|
||||||
self::UNSUPPORTED_ARCHIVE,
|
|
||||||
self::ARCHIVE_EXCEPTION,
|
self::ARCHIVE_EXCEPTION,
|
||||||
self::PACKAGE_FETCH_EXCEPTION,
|
self::PACKAGE_FETCH_EXCEPTION,
|
||||||
self::INVALID_BUILD_CONFIGURATION,
|
self::INVALID_BUILD_CONFIGURATION,
|
||||||
self::INVALID_DEPENDENCY_CONFIGURATION,
|
self::INVALID_DEPENDENCY_CONFIGURATION,
|
||||||
self::SYMLINK_EXCEPTION,
|
self::SYMLINK_EXCEPTION,
|
||||||
self::PATH_NOT_FOUND,
|
self::PATH_NOT_FOUND,
|
||||||
self::GIT_EXCEPTION
|
self::GIT_EXCEPTION,
|
||||||
|
self::RESOURCE_NOT_FOUND,
|
||||||
];
|
];
|
||||||
}
|
}
|
|
@ -1,26 +1,26 @@
|
||||||
<?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
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
* 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
|
* 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
|
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
* conditions:
|
* conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||||
* of the Software.
|
* of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
* 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
|
* 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
|
* 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
|
* 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
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
namespace ncc\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Enums\ExceptionCodes;
|
use ncc\Enums\ExceptionCodes;
|
||||||
|
|
|
@ -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 GitlabServiceException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::GITLAB_SERVICE_EXCEPTION, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +1,26 @@
|
||||||
<?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
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
* 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
|
* 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
|
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
* conditions:
|
* conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||||
* of the Software.
|
* of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
* 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
|
* 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
|
* 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
|
* 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
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
namespace ncc\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Enums\ExceptionCodes;
|
use ncc\Enums\ExceptionCodes;
|
||||||
|
|
|
@ -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 NotImplementedException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::NOT_IMPLEMENTED, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +1,26 @@
|
||||||
<?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
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
* 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
|
* 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
|
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
* conditions:
|
* conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||||
* of the Software.
|
* of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
* 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
|
* 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
|
* 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
|
* 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
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ncc\Exceptions;
|
namespace ncc\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Enums\ExceptionCodes;
|
use ncc\Enums\ExceptionCodes;
|
||||||
|
|
31
src/ncc/Exceptions/ResourceNotFoundException.php
Normal file
31
src/ncc/Exceptions/ResourceNotFoundException.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?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;
|
||||||
|
|
||||||
|
class ResourceNotFoundException extends \Exception
|
||||||
|
{
|
||||||
|
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 UnsupportedArchiveException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::UNSUPPORTED_ARCHIVE, $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 UnsupportedCompilerExtensionException extends Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $message
|
|
||||||
* @param Throwable|null $previous
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, ExceptionCodes::UNSUPPORTED_COMPILER_EXTENSION, $previous);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -42,12 +42,12 @@ namespace ncc\Interfaces;
|
||||||
/**
|
/**
|
||||||
* Returns the release url of the repository, versions can be specified.
|
* Returns the release url of the repository, versions can be specified.
|
||||||
*
|
*
|
||||||
* @param RemotePackageInput $packageInput
|
* @param RemotePackageInput $package_input
|
||||||
* @param DefinedRemoteSource $definedRemoteSource
|
* @param DefinedRemoteSource $defined_remote_source
|
||||||
* @param Entry|null $entry
|
* @param Entry|null $entry
|
||||||
* @return RepositoryQueryResults
|
* @return RepositoryQueryResults
|
||||||
*/
|
*/
|
||||||
public static function getRelease(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults;
|
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the download URL of the pre-compiled .ncc package if available
|
* Returns the download URL of the pre-compiled .ncc package if available
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
use ncc\Exceptions\InvalidScopeException;
|
use ncc\Exceptions\InvalidScopeException;
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\MissingDependencyException;
|
use ncc\Exceptions\MissingDependencyException;
|
||||||
use ncc\Exceptions\NotImplementedException;
|
use ncc\Exceptions\NotSupportedException;
|
||||||
use ncc\Exceptions\PackageAlreadyInstalledException;
|
use ncc\Exceptions\PackageAlreadyInstalledException;
|
||||||
use ncc\Exceptions\PackageFetchException;
|
use ncc\Exceptions\PackageFetchException;
|
||||||
use ncc\Exceptions\PackageLockException;
|
use ncc\Exceptions\PackageLockException;
|
||||||
|
@ -53,7 +53,6 @@
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\RunnerExecutionException;
|
use ncc\Exceptions\RunnerExecutionException;
|
||||||
use ncc\Exceptions\SymlinkException;
|
use ncc\Exceptions\SymlinkException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\VersionNotFoundException;
|
||||||
use ncc\Objects\DefinedRemoteSource;
|
use ncc\Objects\DefinedRemoteSource;
|
||||||
use ncc\Objects\InstallationPaths;
|
use ncc\Objects\InstallationPaths;
|
||||||
|
@ -112,7 +111,7 @@
|
||||||
* @throws InvalidPackageNameException
|
* @throws InvalidPackageNameException
|
||||||
* @throws InvalidScopeException
|
* @throws InvalidScopeException
|
||||||
* @throws MissingDependencyException
|
* @throws MissingDependencyException
|
||||||
* @throws NotImplementedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageAlreadyInstalledException
|
* @throws PackageAlreadyInstalledException
|
||||||
* @throws PackageLockException
|
* @throws PackageLockException
|
||||||
* @throws PackageNotFoundException
|
* @throws PackageNotFoundException
|
||||||
|
@ -120,7 +119,6 @@
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws RunnerExecutionException
|
* @throws RunnerExecutionException
|
||||||
* @throws SymlinkException
|
* @throws SymlinkException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws VersionNotFoundException
|
* @throws VersionNotFoundException
|
||||||
*/
|
*/
|
||||||
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
|
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
|
||||||
|
@ -149,7 +147,7 @@
|
||||||
$installer = match ($extension)
|
$installer = match ($extension)
|
||||||
{
|
{
|
||||||
CompilerExtensions::PHP => new PhpInstaller($package),
|
CompilerExtensions::PHP => new PhpInstaller($package),
|
||||||
default => throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $extension . '\' is not supported'),
|
default => throw new NotSupportedException(sprintf('Compiler extension %s is not supported with ncc', $extension))
|
||||||
};
|
};
|
||||||
|
|
||||||
if($this->getPackageVersion($package->assembly->package, $package->assembly->version) !== null)
|
if($this->getPackageVersion($package->assembly->package, $package->assembly->version) !== null)
|
||||||
|
@ -440,6 +438,7 @@
|
||||||
if($sources_manager->getRemoteSource($package->header->UpdateSource->repository->name) === null)
|
if($sources_manager->getRemoteSource($package->header->UpdateSource->repository->name) === null)
|
||||||
{
|
{
|
||||||
Console::outVerbose('Adding remote source ' . $package->header->UpdateSource->repository->name);
|
Console::outVerbose('Adding remote source ' . $package->header->UpdateSource->repository->name);
|
||||||
|
|
||||||
$defined_remote_source = new DefinedRemoteSource();
|
$defined_remote_source = new DefinedRemoteSource();
|
||||||
$defined_remote_source->name = $package->header->UpdateSource->repository->name;
|
$defined_remote_source->name = $package->header->UpdateSource->repository->name;
|
||||||
$defined_remote_source->host = $package->header->UpdateSource->repository->host;
|
$defined_remote_source->host = $package->header->UpdateSource->repository->host;
|
||||||
|
@ -463,7 +462,7 @@
|
||||||
* @param Entry|null $entry
|
* @param Entry|null $entry
|
||||||
* @return string
|
* @return string
|
||||||
* @throws InstallationException
|
* @throws InstallationException
|
||||||
* @throws NotImplementedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageFetchException
|
* @throws PackageFetchException
|
||||||
*/
|
*/
|
||||||
public function fetchFromSource(string $source, ?Entry $entry=null): string
|
public function fetchFromSource(string $source, ?Entry $entry=null): string
|
||||||
|
@ -504,7 +503,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotImplementedException('Builtin source type ' . $input->source . ' is not implemented');
|
throw new NotSupportedException(sprintf('Builtin source %s is not supported', $input->source));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($remote_source_type === RemoteSourceType::DEFINED)
|
if($remote_source_type === RemoteSourceType::DEFINED)
|
||||||
|
@ -659,7 +658,7 @@
|
||||||
* @throws InvalidPackageNameException
|
* @throws InvalidPackageNameException
|
||||||
* @throws InvalidScopeException
|
* @throws InvalidScopeException
|
||||||
* @throws MissingDependencyException
|
* @throws MissingDependencyException
|
||||||
* @throws NotImplementedException
|
* @throws NotSupportedException
|
||||||
* @throws PackageAlreadyInstalledException
|
* @throws PackageAlreadyInstalledException
|
||||||
* @throws PackageLockException
|
* @throws PackageLockException
|
||||||
* @throws PackageNotFoundException
|
* @throws PackageNotFoundException
|
||||||
|
@ -667,9 +666,7 @@
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws RunnerExecutionException
|
* @throws RunnerExecutionException
|
||||||
* @throws SymlinkException
|
* @throws SymlinkException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws VersionNotFoundException
|
* @throws VersionNotFoundException
|
||||||
* @throws PathNotFoundException
|
|
||||||
*/
|
*/
|
||||||
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
|
||||||
{
|
{
|
||||||
|
@ -728,12 +725,12 @@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException('Dependency source type ' . $dependency->source_type . ' is not implemented');
|
throw new NotSupportedException(sprintf('Dependency source type %s is not supported', $dependency->source_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif(!$dependency_met)
|
elseif(!$dependency_met)
|
||||||
{
|
{
|
||||||
throw new MissingDependencyException(sprintf('The dependency %s=%s for %s=%s is not met', $dependency->name, $dependency->version, $package->assembly->package, $package->assembly->version));
|
throw new PackageNotFoundException(sprintf('Required dependency %s=%s is not installed', $dependency->name, $dependency->version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,9 @@
|
||||||
use ncc\Exceptions\InvalidProjectNameException;
|
use ncc\Exceptions\InvalidProjectNameException;
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\PackagePreparationFailedException;
|
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\ProjectAlreadyExistsException;
|
use ncc\Exceptions\ProjectAlreadyExistsException;
|
||||||
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
|
||||||
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;
|
||||||
|
@ -294,7 +292,6 @@
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
* @throws ProjectConfigurationNotFoundException
|
* @throws ProjectConfigurationNotFoundException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
*/
|
*/
|
||||||
public function build(string $build_configuration=BuildConfigurationValues::DEFAULT): string
|
public function build(string $build_configuration=BuildConfigurationValues::DEFAULT): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Enums\Options\BuildConfigurationValues;
|
use ncc\Enums\Options\BuildConfigurationValues;
|
||||||
use ncc\Exceptions\AccessDeniedException;
|
|
||||||
use ncc\Exceptions\BuildConfigurationNotFoundException;
|
use ncc\Exceptions\BuildConfigurationNotFoundException;
|
||||||
use ncc\Exceptions\InvalidBuildConfigurationException;
|
use ncc\Exceptions\InvalidBuildConfigurationException;
|
||||||
use ncc\Exceptions\InvalidConstantNameException;
|
use ncc\Exceptions\InvalidConstantNameException;
|
||||||
|
@ -38,8 +37,6 @@
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Exceptions\UndefinedExecutionPolicyException;
|
use ncc\Exceptions\UndefinedExecutionPolicyException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
|
||||||
use ncc\Exceptions\UnsupportedExtensionVersionException;
|
|
||||||
use ncc\Interfaces\BytecodeObjectInterface;
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Objects\ProjectConfiguration\Assembly;
|
use ncc\Objects\ProjectConfiguration\Assembly;
|
||||||
use ncc\Objects\ProjectConfiguration\Build;
|
use ncc\Objects\ProjectConfiguration\Build;
|
||||||
|
@ -113,8 +110,6 @@
|
||||||
* @throws InvalidPropertyValueException
|
* @throws InvalidPropertyValueException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws UndefinedExecutionPolicyException
|
* @throws UndefinedExecutionPolicyException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws UnsupportedExtensionVersionException
|
|
||||||
* @throws InvalidBuildConfigurationException
|
* @throws InvalidBuildConfigurationException
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
|
@ -403,7 +398,6 @@
|
||||||
*
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return ProjectConfiguration
|
* @return ProjectConfiguration
|
||||||
* @throws AccessDeniedException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
|
|
|
@ -29,9 +29,8 @@
|
||||||
use ncc\Enums\CompilerExtensionSupportedVersions;
|
use ncc\Enums\CompilerExtensionSupportedVersions;
|
||||||
use ncc\Exceptions\InvalidPropertyValueException;
|
use ncc\Exceptions\InvalidPropertyValueException;
|
||||||
use ncc\Exceptions\InvalidVersionConfigurationException;
|
use ncc\Exceptions\InvalidVersionConfigurationException;
|
||||||
|
use ncc\Exceptions\NotSupportedException;
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
|
||||||
use ncc\Exceptions\UnsupportedExtensionVersionException;
|
|
||||||
use ncc\Interfaces\BytecodeObjectInterface;
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
@ -69,9 +68,8 @@
|
||||||
* @param bool $throw_exception
|
* @param bool $throw_exception
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws InvalidPropertyValueException
|
* @throws InvalidPropertyValueException
|
||||||
|
* @throws NotSupportedException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws UnsupportedExtensionVersionException
|
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
{
|
{
|
||||||
|
@ -126,7 +124,7 @@
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->extension . '\' is not supported');
|
throw new NotSupportedException('The compiler extension \'' . $this->extension . '\' is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
|
@ -139,7 +137,7 @@
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
throw new UnsupportedExtensionVersionException('The MaximumVersion does not support version ' . $this->maximum_version . ' for the extension ' . $this->extension);
|
throw new NotSupportedException('The MaximumVersion does not support version ' . $this->maximum_version . ' for the extension ' . $this->extension);
|
||||||
}
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
@ -148,14 +146,14 @@
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
throw new UnsupportedExtensionVersionException('The MinimumVersion does not support version ' . $this->minimum_version . ' for the extension ' . $this->extension);
|
throw new NotSupportedException('The MinimumVersion does not support version ' . $this->minimum_version . ' for the extension ' . $this->extension);
|
||||||
}
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->extension . '\' is not supported');
|
throw new NotSupportedException('The compiler extension \'' . $this->extension . '\' is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
|
|
||||||
use ncc\Exceptions\InvalidPropertyValueException;
|
use ncc\Exceptions\InvalidPropertyValueException;
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
|
||||||
use ncc\Exceptions\UnsupportedExtensionVersionException;
|
|
||||||
use ncc\Interfaces\BytecodeObjectInterface;
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
|
@ -68,8 +66,6 @@
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws InvalidPropertyValueException
|
* @throws InvalidPropertyValueException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws UnsupportedCompilerExtensionException
|
|
||||||
* @throws UnsupportedExtensionVersionException
|
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
<?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
|
||||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
* 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
|
* 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
|
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||||
* conditions:
|
* conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||||
* of the Software.
|
* of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
* 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
|
* 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
|
* 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
|
* 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
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
|
|
||||||
if($version === Versions::LATEST)
|
if($version === Versions::LATEST)
|
||||||
{
|
{
|
||||||
$version = $package_entry->getLatestVersion();
|
$version = $package_entry?->getLatestVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
|
|
||||||
if($version_entry === null)
|
if($version_entry === null)
|
||||||
{
|
{
|
||||||
throw new VersionNotFoundException();
|
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (VersionNotFoundException $e)
|
catch (VersionNotFoundException $e)
|
||||||
|
|
|
@ -42,13 +42,11 @@
|
||||||
use ncc\Exceptions\AccessDeniedException;
|
use ncc\Exceptions\AccessDeniedException;
|
||||||
use ncc\Exceptions\ArchiveException;
|
use ncc\Exceptions\ArchiveException;
|
||||||
use ncc\Exceptions\AuthenticationException;
|
use ncc\Exceptions\AuthenticationException;
|
||||||
use ncc\Exceptions\GitlabServiceException;
|
|
||||||
use ncc\Exceptions\HttpException;
|
use ncc\Exceptions\HttpException;
|
||||||
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\RunnerExecutionException;
|
use ncc\Exceptions\RunnerExecutionException;
|
||||||
use ncc\Exceptions\UnsupportedArchiveException;
|
|
||||||
use ncc\Managers\ConfigurationManager;
|
use ncc\Managers\ConfigurationManager;
|
||||||
use ncc\Managers\CredentialManager;
|
use ncc\Managers\CredentialManager;
|
||||||
use ncc\Managers\PackageLockManager;
|
use ncc\Managers\PackageLockManager;
|
||||||
|
@ -123,7 +121,6 @@
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws AccessDeniedException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
|
@ -231,8 +228,8 @@
|
||||||
* @param string $copyright
|
* @param string $copyright
|
||||||
* @param bool $basic_ascii
|
* @param bool $basic_ascii
|
||||||
* @return string
|
* @return string
|
||||||
* @throws AccessDeniedException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @throws PathNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function getBanner(string $version, string $copyright, bool $basic_ascii=false): string
|
public static function getBanner(string $version, string $copyright, bool $basic_ascii=false): string
|
||||||
{
|
{
|
||||||
|
@ -424,9 +421,9 @@
|
||||||
*
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return ComposerJson
|
* @return ComposerJson
|
||||||
* @throws AccessDeniedException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws MalformedJsonException
|
* @throws MalformedJsonException
|
||||||
|
* @throws PathNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function loadComposerJson(string $path): ComposerJson
|
public static function loadComposerJson(string $path): ComposerJson
|
||||||
{
|
{
|
||||||
|
@ -568,7 +565,6 @@
|
||||||
* @param bool $expect_json
|
* @param bool $expect_json
|
||||||
* @return HttpRequest
|
* @return HttpRequest
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitlabServiceException
|
|
||||||
*/
|
*/
|
||||||
public static function prepareGitServiceRequest(HttpRequest $http_request, ?Entry $entry=null, bool $expect_json=true): HttpRequest
|
public static function prepareGitServiceRequest(HttpRequest $http_request, ?Entry $entry=null, bool $expect_json=true): HttpRequest
|
||||||
{
|
{
|
||||||
|
@ -576,7 +572,7 @@
|
||||||
{
|
{
|
||||||
if(!$entry->isCurrentlyDecrypted())
|
if(!$entry->isCurrentlyDecrypted())
|
||||||
{
|
{
|
||||||
throw new GitlabServiceException('The given Vault entry is not decrypted.');
|
throw new RuntimeException('The given Vault entry is not decrypted.');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($entry->getPassword()?->getAuthenticationType())
|
switch ($entry->getPassword()?->getAuthenticationType())
|
||||||
|
@ -586,7 +582,7 @@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AuthenticationType::USERNAME_PASSWORD:
|
case AuthenticationType::USERNAME_PASSWORD:
|
||||||
throw new AuthenticationException('Username/Password authentication is not supported');
|
throw new AuthenticationException(sprintf('The given Vault entry is using the %s authentication type, which is not supported for Gitlab', AuthenticationType::USERNAME_PASSWORD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +602,6 @@
|
||||||
* @param Entry|null $entry
|
* @param Entry|null $entry
|
||||||
* @return string
|
* @return string
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws GitlabServiceException
|
|
||||||
* @throws HttpException
|
* @throws HttpException
|
||||||
*/
|
*/
|
||||||
public static function downloadGitServiceFile(string $url, ?Entry $entry=null): string
|
public static function downloadGitServiceFile(string $url, ?Entry $entry=null): string
|
||||||
|
@ -633,7 +628,6 @@
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* @throws ArchiveException
|
* @throws ArchiveException
|
||||||
* @throws UnsupportedArchiveException
|
|
||||||
*/
|
*/
|
||||||
public static function extractArchive(string $path): ?string
|
public static function extractArchive(string $path): ?string
|
||||||
{
|
{
|
||||||
|
@ -650,12 +644,12 @@
|
||||||
|
|
||||||
RuntimeCache::setFileAsTemporary($out_path);
|
RuntimeCache::setFileAsTemporary($out_path);
|
||||||
|
|
||||||
$mimeType = mime_content_type($path);
|
$mime_type = mime_content_type($path);
|
||||||
$supportedTypes = [];
|
$supported_types = [];
|
||||||
|
|
||||||
if($unzip_executable !== null)
|
if($unzip_executable !== null)
|
||||||
{
|
{
|
||||||
$supportedTypes = array_merge($supportedTypes, [
|
$supported_types = array_merge($supported_types, [
|
||||||
'application/zip',
|
'application/zip',
|
||||||
'application/x-zip',
|
'application/x-zip',
|
||||||
'application/x-zip-compressed',
|
'application/x-zip-compressed',
|
||||||
|
@ -673,7 +667,7 @@
|
||||||
|
|
||||||
if($tar_executable !== null)
|
if($tar_executable !== null)
|
||||||
{
|
{
|
||||||
$supportedTypes = array_merge($supportedTypes, [
|
$supported_types = array_merge($supported_types, [
|
||||||
'application/x-tar',
|
'application/x-tar',
|
||||||
'application/x-gzip',
|
'application/x-gzip',
|
||||||
'application/x-bzip2',
|
'application/x-bzip2',
|
||||||
|
@ -686,17 +680,17 @@
|
||||||
RuntimeCache::set('warning_tar_shown', true);
|
RuntimeCache::set('warning_tar_shown', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($mimeType, $supportedTypes, true))
|
if(!in_array($mime_type, $supported_types, true))
|
||||||
{
|
{
|
||||||
throw new UnsupportedArchiveException("Unsupported archive type: $mimeType");
|
throw new ArchiveException(sprintf('Cannot extract archive %s, unsupported archive type %s', $path, $mime_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = match ($mimeType) {
|
$command = match ($mime_type) {
|
||||||
'application/zip' => [$unzip_executable, $path, '-d', $out_path],
|
'application/zip' => [$unzip_executable, $path, '-d', $out_path],
|
||||||
'application/x-tar' => [$tar_executable, '--verbose', '-xf', $path, '-C', $out_path],
|
'application/x-tar' => [$tar_executable, '--verbose', '-xf', $path, '-C', $out_path],
|
||||||
'application/x-gzip' => [$tar_executable, '--verbose', '-xzf', $path, '-C', $out_path],
|
'application/x-gzip' => [$tar_executable, '--verbose', '-xzf', $path, '-C', $out_path],
|
||||||
'application/x-bzip2' => [$tar_executable, '--verbose', '-xjf', $path, '-C', $out_path],
|
'application/x-bzip2' => [$tar_executable, '--verbose', '-xjf', $path, '-C', $out_path],
|
||||||
default => throw new UnsupportedArchiveException("Unsupported archive type: $mimeType"),
|
default => throw new ArchiveException(sprintf('Cannot extract archive %s, unsupported archive type %s', $path, $mime_type)),
|
||||||
};
|
};
|
||||||
|
|
||||||
Console::out("Extracting archive $path");
|
Console::out("Extracting archive $path");
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
namespace ncc\Utilities;
|
namespace ncc\Utilities;
|
||||||
|
|
||||||
use ncc\Exceptions\AccessDeniedException;
|
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\PathNotFoundException;
|
use ncc\Exceptions\PathNotFoundException;
|
||||||
use SplFileInfo;
|
use SplFileInfo;
|
||||||
|
@ -81,7 +80,6 @@
|
||||||
* @param string $mode
|
* @param string $mode
|
||||||
* @param int|null $length
|
* @param int|null $length
|
||||||
* @return string
|
* @return string
|
||||||
* @throws AccessDeniedException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws PathNotFoundException
|
* @throws PathNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@ -101,7 +99,7 @@
|
||||||
|
|
||||||
if(!is_readable($uri))
|
if(!is_readable($uri))
|
||||||
{
|
{
|
||||||
throw new AccessDeniedException(sprintf('Unable to read file: (%s)', $uri));
|
throw new IOException(sprintf('Unable to read file (permission issue?): (%s)', $uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = new SplFileObject($uri, $mode);
|
$file = new SplFileObject($uri, $mode);
|
||||||
|
|
Loading…
Add table
Reference in a new issue