1.0.0 Alpha Release #59
1 changed files with 19 additions and 21 deletions
|
@ -5,14 +5,10 @@
|
|||
use Exception;
|
||||
use ncc\Abstracts\CompilerExtensions;
|
||||
use ncc\Abstracts\ConstantReferences;
|
||||
use ncc\Abstracts\DefinedRemoteSourceType;
|
||||
use ncc\Abstracts\LogLevel;
|
||||
use ncc\Abstracts\Options\BuildConfigurationValues;
|
||||
use ncc\Abstracts\ProjectType;
|
||||
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\CLI\Main;
|
||||
use ncc\Exceptions\AccessDeniedException;
|
||||
|
@ -21,24 +17,17 @@
|
|||
use ncc\Exceptions\FileNotFoundException;
|
||||
use ncc\Exceptions\IOException;
|
||||
use ncc\Exceptions\MalformedJsonException;
|
||||
use ncc\Exceptions\PackageFetchException;
|
||||
use ncc\Exceptions\PackagePreparationFailedException;
|
||||
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
||||
use ncc\Exceptions\UnsupportedProjectTypeException;
|
||||
use ncc\Exceptions\UnsupportedRemoteSourceTypeException;
|
||||
use ncc\Exceptions\UnsupportedRunnerException;
|
||||
use ncc\Interfaces\CompilerInterface;
|
||||
use ncc\Interfaces\RepositorySourceInterface;
|
||||
use ncc\Managers\ProjectManager;
|
||||
use ncc\ncc;
|
||||
use ncc\Objects\DefinedRemoteSource;
|
||||
use ncc\Objects\Package;
|
||||
use ncc\Objects\ProjectConfiguration;
|
||||
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\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
@ -103,35 +92,44 @@
|
|||
* Returns the compiled package path
|
||||
*
|
||||
* @param string $path
|
||||
* @param string|null $version
|
||||
* @return string
|
||||
* @throws BuildException
|
||||
* @throws UnsupportedProjectTypeException
|
||||
*/
|
||||
public static function tryCompile(string $path, ?string $version=null): string
|
||||
{
|
||||
$project_type = Resolver::detectProjectType($path);
|
||||
|
||||
if($version !== null)
|
||||
$version = Functions::convertToSemVer($version);
|
||||
|
||||
try
|
||||
{
|
||||
if($project_type->ProjectType == ProjectType::Composer)
|
||||
return ComposerSourceBuiltin::fromLocal($project_type->ProjectPath);
|
||||
|
||||
if($project_type->ProjectType == ProjectType::Ncc)
|
||||
{
|
||||
$project_path = ComposerSourceBuiltin::fromLocal($project_type->ProjectPath);
|
||||
}
|
||||
elseif($project_type->ProjectType == ProjectType::Ncc)
|
||||
{
|
||||
$project_manager = new ProjectManager($project_type->ProjectPath);
|
||||
$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)
|
||||
{
|
||||
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