Updated method \ncc\Classes\NccExtension > PackageCompiler > tryCompile() to apply the correct version to the target package if a version is specified.
This commit is contained in:
parent
61146d1b1d
commit
570b21ca3d
1 changed files with 19 additions and 21 deletions
|
@ -5,14 +5,10 @@
|
||||||
use Exception;
|
use Exception;
|
||||||
use ncc\Abstracts\CompilerExtensions;
|
use ncc\Abstracts\CompilerExtensions;
|
||||||
use ncc\Abstracts\ConstantReferences;
|
use ncc\Abstracts\ConstantReferences;
|
||||||
use ncc\Abstracts\DefinedRemoteSourceType;
|
|
||||||
use ncc\Abstracts\LogLevel;
|
use ncc\Abstracts\LogLevel;
|
||||||
use ncc\Abstracts\Options\BuildConfigurationValues;
|
use ncc\Abstracts\Options\BuildConfigurationValues;
|
||||||
use ncc\Abstracts\ProjectType;
|
use ncc\Abstracts\ProjectType;
|
||||||
use ncc\Classes\ComposerExtension\ComposerSourceBuiltin;
|
use ncc\Classes\ComposerExtension\ComposerSourceBuiltin;
|
||||||
use ncc\Classes\GitClient;
|
|
||||||
use ncc\Classes\GithubExtension\GithubService;
|
|
||||||
use ncc\Classes\GitlabExtension\GitlabService;
|
|
||||||
use ncc\Classes\PhpExtension\PhpCompiler;
|
use ncc\Classes\PhpExtension\PhpCompiler;
|
||||||
use ncc\CLI\Main;
|
use ncc\CLI\Main;
|
||||||
use ncc\Exceptions\AccessDeniedException;
|
use ncc\Exceptions\AccessDeniedException;
|
||||||
|
@ -21,24 +17,17 @@
|
||||||
use ncc\Exceptions\FileNotFoundException;
|
use ncc\Exceptions\FileNotFoundException;
|
||||||
use ncc\Exceptions\IOException;
|
use ncc\Exceptions\IOException;
|
||||||
use ncc\Exceptions\MalformedJsonException;
|
use ncc\Exceptions\MalformedJsonException;
|
||||||
use ncc\Exceptions\PackageFetchException;
|
|
||||||
use ncc\Exceptions\PackagePreparationFailedException;
|
use ncc\Exceptions\PackagePreparationFailedException;
|
||||||
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
||||||
use ncc\Exceptions\UnsupportedProjectTypeException;
|
use ncc\Exceptions\UnsupportedProjectTypeException;
|
||||||
use ncc\Exceptions\UnsupportedRemoteSourceTypeException;
|
|
||||||
use ncc\Exceptions\UnsupportedRunnerException;
|
use ncc\Exceptions\UnsupportedRunnerException;
|
||||||
use ncc\Interfaces\CompilerInterface;
|
use ncc\Interfaces\CompilerInterface;
|
||||||
use ncc\Interfaces\RepositorySourceInterface;
|
|
||||||
use ncc\Managers\ProjectManager;
|
use ncc\Managers\ProjectManager;
|
||||||
use ncc\ncc;
|
use ncc\ncc;
|
||||||
use ncc\Objects\DefinedRemoteSource;
|
|
||||||
use ncc\Objects\Package;
|
use ncc\Objects\Package;
|
||||||
use ncc\Objects\ProjectConfiguration;
|
use ncc\Objects\ProjectConfiguration;
|
||||||
use ncc\Objects\ProjectConfiguration\Assembly;
|
use ncc\Objects\ProjectConfiguration\Assembly;
|
||||||
use ncc\Objects\RemotePackageInput;
|
|
||||||
use ncc\Objects\Vault\Entry;
|
|
||||||
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
|
||||||
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
|
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
|
||||||
use ncc\Utilities\Console;
|
use ncc\Utilities\Console;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
@ -103,35 +92,44 @@
|
||||||
* Returns the compiled package path
|
* Returns the compiled package path
|
||||||
*
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
|
* @param string|null $version
|
||||||
* @return string
|
* @return string
|
||||||
* @throws BuildException
|
* @throws BuildException
|
||||||
* @throws UnsupportedProjectTypeException
|
|
||||||
*/
|
*/
|
||||||
public static function tryCompile(string $path, ?string $version=null): string
|
public static function tryCompile(string $path, ?string $version=null): string
|
||||||
{
|
{
|
||||||
$project_type = Resolver::detectProjectType($path);
|
$project_type = Resolver::detectProjectType($path);
|
||||||
|
|
||||||
if($version !== null)
|
|
||||||
$version = Functions::convertToSemVer($version);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if($project_type->ProjectType == ProjectType::Composer)
|
if($project_type->ProjectType == ProjectType::Composer)
|
||||||
return ComposerSourceBuiltin::fromLocal($project_type->ProjectPath);
|
{
|
||||||
|
$project_path = ComposerSourceBuiltin::fromLocal($project_type->ProjectPath);
|
||||||
if($project_type->ProjectType == ProjectType::Ncc)
|
}
|
||||||
|
elseif($project_type->ProjectType == ProjectType::Ncc)
|
||||||
{
|
{
|
||||||
$project_manager = new ProjectManager($project_type->ProjectPath);
|
$project_manager = new ProjectManager($project_type->ProjectPath);
|
||||||
$project_manager->getProjectConfiguration()->Assembly->Version = $version;
|
$project_manager->getProjectConfiguration()->Assembly->Version = $version;
|
||||||
return $project_manager->build();
|
$project_path = $project_manager->build();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new UnsupportedProjectTypeException('The project type \'' . $project_type->ProjectType . '\' is not supported');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($version !== null)
|
||||||
|
{
|
||||||
|
$package = Package::load($project_path);
|
||||||
|
$package->Assembly->Version = Functions::convertToSemVer($version);
|
||||||
|
$package->save($project_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $project_path;
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
throw new BuildException('Failed to build project', $e);
|
throw new BuildException('Failed to build project', $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnsupportedProjectTypeException('The project type \'' . $project_type->ProjectType . '\' is not supported');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue