- Implemented interface BytecodeObjectInterface
into \ncc\Objects\ProjectConfiguration > Assembly
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\UpdateSource > Repository` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > Execute` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > ExitHandle` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > ExitHandlers` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\Build > BuildConfiguration`
This commit is contained in:
parent
15fd06d2d0
commit
348ca2d4a1
27 changed files with 651 additions and 570 deletions
|
@ -98,6 +98,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Dependecy`
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Dependecy`
|
||||||
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Compiler`
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Compiler`
|
||||||
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Build`
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Build`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Assembly`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\UpdateSource > Repository`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > Execute`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > ExitHandle`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > ExitHandlers`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\Build > BuildConfiguration`
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
||||||
|
|
|
@ -448,49 +448,49 @@
|
||||||
|
|
||||||
Console::out('Package installation details' . PHP_EOL);
|
Console::out('Package installation details' . PHP_EOL);
|
||||||
|
|
||||||
if(!is_null($package->assembly->UUID))
|
if(!is_null($package->assembly->uuid))
|
||||||
{
|
{
|
||||||
Console::out(' UUID: ' . Console::formatColor($package->assembly->UUID, ConsoleColors::LIGHT_GREEN));
|
Console::out(' UUID: ' . Console::formatColor($package->assembly->uuid, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Package))
|
if(!is_null($package->assembly->package))
|
||||||
{
|
{
|
||||||
Console::out(' Package: ' . Console::formatColor($package->assembly->Package, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Package: ' . Console::formatColor($package->assembly->package, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Name))
|
if(!is_null($package->assembly->name))
|
||||||
{
|
{
|
||||||
Console::out(' Name: ' . Console::formatColor($package->assembly->Name, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Name: ' . Console::formatColor($package->assembly->name, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Version))
|
if(!is_null($package->assembly->version))
|
||||||
{
|
{
|
||||||
Console::out(' Version: ' . Console::formatColor($package->assembly->Version, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Version: ' . Console::formatColor($package->assembly->version, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Description))
|
if(!is_null($package->assembly->description))
|
||||||
{
|
{
|
||||||
Console::out(' Description: ' . Console::formatColor($package->assembly->Description, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Description: ' . Console::formatColor($package->assembly->description, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Product))
|
if(!is_null($package->assembly->product))
|
||||||
{
|
{
|
||||||
Console::out(' Product: ' . Console::formatColor($package->assembly->Product, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Product: ' . Console::formatColor($package->assembly->product, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Company))
|
if(!is_null($package->assembly->company))
|
||||||
{
|
{
|
||||||
Console::out(' Company: ' . Console::formatColor($package->assembly->Company, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Company: ' . Console::formatColor($package->assembly->company, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Copyright))
|
if(!is_null($package->assembly->copyright))
|
||||||
{
|
{
|
||||||
Console::out(' Copyright: ' . Console::formatColor($package->assembly->Copyright, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Copyright: ' . Console::formatColor($package->assembly->copyright, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($package->assembly->Trademark))
|
if(!is_null($package->assembly->trademark))
|
||||||
{
|
{
|
||||||
Console::out(' Trademark: ' . Console::formatColor($package->assembly->Trademark, ConsoleColors::LIGHT_GREEN));
|
Console::out(' Trademark: ' . Console::formatColor($package->assembly->trademark, ConsoleColors::LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
Console::out((string)null);
|
Console::out((string)null);
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@
|
||||||
|
|
||||||
if(!$user_confirmation)
|
if(!$user_confirmation)
|
||||||
{
|
{
|
||||||
$user_confirmation = Console::getBooleanInput(sprintf('Do you want to install %s', $package->assembly->Package));
|
$user_confirmation = Console::getBooleanInput(sprintf('Do you want to install %s', $package->assembly->package));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($user_confirmation)
|
if($user_confirmation)
|
||||||
|
@ -578,7 +578,7 @@
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$package_manager->install($path, $credential, $installer_options);
|
$package_manager->install($path, $credential, $installer_options);
|
||||||
Console::out(sprintf('Package %s installed successfully', $package->assembly->Package));
|
Console::out(sprintf('Package %s installed successfully', $package->assembly->package));
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace ncc\Classes\BashExtension;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
$policy->execute->Target = null;
|
$policy->execute->target = null;
|
||||||
|
|
||||||
return $execution_unit;
|
return $execution_unit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,10 +259,10 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
$built_package = $project_manager->build();
|
$built_package = $project_manager->build();
|
||||||
|
|
||||||
// Copy the project to the build directory
|
// Copy the project to the build directory
|
||||||
$out_path = $base_dir . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . sprintf('%s.ncc', $project_configuration->assembly->Package);
|
$out_path = $base_dir . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . sprintf('%s.ncc', $project_configuration->assembly->package);
|
||||||
$filesystem->copy($built_package, $out_path);
|
$filesystem->copy($built_package, $out_path);
|
||||||
$filesystem->remove($built_package);
|
$filesystem->remove($built_package);
|
||||||
$built_packages[$project_configuration->assembly->Package] = $out_path;
|
$built_packages[$project_configuration->assembly->package] = $out_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $built_packages;
|
return $built_packages;
|
||||||
|
@ -340,27 +340,27 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
|
|
||||||
if (isset($composer_package->Name))
|
if (isset($composer_package->Name))
|
||||||
{
|
{
|
||||||
$project_configuration->assembly->Name = $composer_package->Name;
|
$project_configuration->assembly->name = $composer_package->Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($composer_package->Description))
|
if (isset($composer_package->Description))
|
||||||
{
|
{
|
||||||
$project_configuration->assembly->Description = $composer_package->Description;
|
$project_configuration->assembly->description = $composer_package->Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($version_map[$composer_package->Name]))
|
if(isset($version_map[$composer_package->Name]))
|
||||||
{
|
{
|
||||||
$project_configuration->assembly->Version = self::versionMap($composer_package->Name, $version_map);
|
$project_configuration->assembly->version = self::versionMap($composer_package->Name, $version_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($project_configuration->assembly->Version === null || $project_configuration->assembly->Version === '')
|
if($project_configuration->assembly->version === null || $project_configuration->assembly->version === '')
|
||||||
{
|
{
|
||||||
$project_configuration->assembly->Version = '1.0.0';
|
$project_configuration->assembly->version = '1.0.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$project_configuration->assembly->UUID = Uuid::v1()->toRfc4122();
|
$project_configuration->assembly->uuid = Uuid::v1()->toRfc4122();
|
||||||
$project_configuration->assembly->Package = self::toPackageName($composer_package->Name);
|
$project_configuration->assembly->package = self::toPackageName($composer_package->Name);
|
||||||
|
|
||||||
// Add the update source
|
// Add the update source
|
||||||
$project_configuration->project->update_source = new ProjectConfiguration\UpdateSource();
|
$project_configuration->project->update_source = new ProjectConfiguration\UpdateSource();
|
||||||
|
@ -391,8 +391,8 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
|
|
||||||
// Create a build configuration
|
// Create a build configuration
|
||||||
$build_configuration = new ProjectConfiguration\Build\BuildConfiguration();
|
$build_configuration = new ProjectConfiguration\Build\BuildConfiguration();
|
||||||
$build_configuration->Name = 'default';
|
$build_configuration->name = 'default';
|
||||||
$build_configuration->OutputPath = 'build';
|
$build_configuration->output_path = 'build';
|
||||||
|
|
||||||
// Apply the final properties
|
// Apply the final properties
|
||||||
$project_configuration->build->build_configurations[] = $build_configuration;
|
$project_configuration->build->build_configurations[] = $build_configuration;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace ncc\Classes\LuaExtension;
|
||||||
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
||||||
{
|
{
|
||||||
$execution_unit = new ExecutionUnit();
|
$execution_unit = new ExecutionUnit();
|
||||||
$policy->execute->Target = null;
|
$policy->execute->target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -46,49 +46,49 @@ namespace ncc\Classes\NccExtension;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Name !== null)
|
if($assembly->name !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_NAME, $assembly->Name, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_NAME, $assembly->name, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Package !== null)
|
if($assembly->package !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_PACKAGE, $assembly->Package, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_PACKAGE, $assembly->package, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Description !== null)
|
if($assembly->description !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_DESCRIPTION, $assembly->Description, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_DESCRIPTION, $assembly->description, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Company !== null)
|
if($assembly->company !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_COMPANY, $assembly->Company, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_COMPANY, $assembly->company, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Product !== null)
|
if($assembly->product !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_PRODUCT, $assembly->Product, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_PRODUCT, $assembly->product, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Copyright !== null)
|
if($assembly->copyright !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_COPYRIGHT, $assembly->Copyright, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_COPYRIGHT, $assembly->copyright, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Trademark !== null)
|
if($assembly->trademark !== null)
|
||||||
{
|
{
|
||||||
$input =str_replace(AssemblyConstants::ASSEMBLY_TRADEMARK, $assembly->Trademark, $input);
|
$input =str_replace(AssemblyConstants::ASSEMBLY_TRADEMARK, $assembly->trademark, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->Version !== null)
|
if($assembly->version !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_VERSION, $assembly->Version, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_VERSION, $assembly->version, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($assembly->UUID !== null)
|
if($assembly->uuid !== null)
|
||||||
{
|
{
|
||||||
$input = str_replace(AssemblyConstants::ASSEMBLY_UID, $assembly->UUID, $input);
|
$input = str_replace(AssemblyConstants::ASSEMBLY_UID, $assembly->uuid, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $input;
|
return $input;
|
||||||
|
|
|
@ -96,8 +96,8 @@
|
||||||
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $configuration->project->compiler->extension . '\' is not supported');
|
throw new UnsupportedCompilerExtensionException('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;
|
||||||
Console::out(sprintf('Building %s=%s', $configuration->assembly->Package, $configuration->assembly->Version));
|
Console::out(sprintf('Building %s=%s', $configuration->assembly->package, $configuration->assembly->version));
|
||||||
$Compiler->prepare($build_configuration);
|
$Compiler->prepare($build_configuration);
|
||||||
$Compiler->build();
|
$Compiler->build();
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
elseif($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;
|
||||||
$project_path = $project_manager->build();
|
$project_path = $project_manager->build();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
if($version !== null)
|
if($version !== null)
|
||||||
{
|
{
|
||||||
$package = Package::load($project_path);
|
$package = Package::load($project_path);
|
||||||
$package->assembly->Version = Functions::convertToSemVer($version);
|
$package->assembly->version = Functions::convertToSemVer($version);
|
||||||
$package->save($project_path);
|
$package->save($project_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
Console::inlineProgressBar($processed_items, $total_items);
|
Console::inlineProgressBar($processed_items, $total_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
$unit_path = Functions::correctDirectorySeparator($path . $policy->execute->Target);
|
$unit_path = Functions::correctDirectorySeparator($path . $policy->execute->target);
|
||||||
$execution_units[] = Functions::compileRunner($unit_path, $policy);
|
$execution_units[] = Functions::compileRunner($unit_path, $policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,15 +216,15 @@
|
||||||
// Write the package to disk
|
// Write the package to disk
|
||||||
$FileSystem = new Filesystem();
|
$FileSystem = new Filesystem();
|
||||||
$BuildConfiguration = $configuration->build->getBuildConfiguration($build_configuration);
|
$BuildConfiguration = $configuration->build->getBuildConfiguration($build_configuration);
|
||||||
if(!$FileSystem->exists($path . $BuildConfiguration->OutputPath))
|
if(!$FileSystem->exists($path . $BuildConfiguration->output_path))
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('creating output directory %s', $path . $BuildConfiguration->OutputPath));
|
Console::outDebug(sprintf('creating output directory %s', $path . $BuildConfiguration->output_path));
|
||||||
$FileSystem->mkdir($path . $BuildConfiguration->OutputPath);
|
$FileSystem->mkdir($path . $BuildConfiguration->output_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally write the package to the disk
|
// Finally write the package to the disk
|
||||||
$FileSystem->mkdir($path . $BuildConfiguration->OutputPath);
|
$FileSystem->mkdir($path . $BuildConfiguration->output_path);
|
||||||
$output_file = $path . $BuildConfiguration->OutputPath . DIRECTORY_SEPARATOR . $package->assembly->Package . '.ncc';
|
$output_file = $path . $BuildConfiguration->output_path . DIRECTORY_SEPARATOR . $package->assembly->package . '.ncc';
|
||||||
if($FileSystem->exists($output_file))
|
if($FileSystem->exists($output_file))
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('removing existing package %s', $output_file));
|
Console::outDebug(sprintf('removing existing package %s', $output_file));
|
||||||
|
@ -327,42 +327,42 @@
|
||||||
|
|
||||||
if($unit->execution_policy->exit_handlers !== null)
|
if($unit->execution_policy->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->exit_handlers->Success !== null)
|
if($unit->execution_policy->exit_handlers->success !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->exit_handlers->Success->Message = self::compileConstants($unit->execution_policy->exit_handlers->Success->Message, $refs);
|
$unit->execution_policy->exit_handlers->success->message = self::compileConstants($unit->execution_policy->exit_handlers->success->message, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->exit_handlers->Error !== null)
|
if($unit->execution_policy->exit_handlers->error !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->exit_handlers->Error->Message = self::compileConstants($unit->execution_policy->exit_handlers->Error->Message, $refs);
|
$unit->execution_policy->exit_handlers->error->message = self::compileConstants($unit->execution_policy->exit_handlers->error->message, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->exit_handlers->Warning !== null)
|
if($unit->execution_policy->exit_handlers->warning !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->exit_handlers->Warning->Message = self::compileConstants($unit->execution_policy->exit_handlers->Warning->Message, $refs);
|
$unit->execution_policy->exit_handlers->warning->message = self::compileConstants($unit->execution_policy->exit_handlers->warning->message, $refs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->execute !== null)
|
if($unit->execution_policy->execute !== null)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->execute->Target !== null)
|
if($unit->execution_policy->execute->target !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->execute->Target = self::compileConstants($unit->execution_policy->execute->Target, $refs);
|
$unit->execution_policy->execute->target = self::compileConstants($unit->execution_policy->execute->target, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->execute->WorkingDirectory !== null)
|
if($unit->execution_policy->execute->working_directory !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->execute->WorkingDirectory = self::compileConstants($unit->execution_policy->execute->WorkingDirectory, $refs);
|
$unit->execution_policy->execute->working_directory = self::compileConstants($unit->execution_policy->execute->working_directory, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->execute->Options !== null && count($unit->execution_policy->execute->Options) > 0)
|
if($unit->execution_policy->execute->options !== null && count($unit->execution_policy->execute->options) > 0)
|
||||||
{
|
{
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach($unit->execution_policy->execute->Options as $key=> $value)
|
foreach($unit->execution_policy->execute->options as $key=> $value)
|
||||||
{
|
{
|
||||||
$options[self::compileConstants($key, $refs)] = self::compileConstants($value, $refs);
|
$options[self::compileConstants($key, $refs)] = self::compileConstants($value, $refs);
|
||||||
}
|
}
|
||||||
$unit->execution_policy->execute->Options = $options;
|
$unit->execution_policy->execute->options = $options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
||||||
{
|
{
|
||||||
$execution_unit = new ExecutionUnit();
|
$execution_unit = new ExecutionUnit();
|
||||||
$policy->execute->Target = null;
|
$policy->execute->target = null;
|
||||||
|
|
||||||
if(!file_exists($path) && !is_file($path))
|
if(!file_exists($path) && !is_file($path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
// Global constants are overridden
|
// Global constants are overridden
|
||||||
$this->package->header->RuntimeConstants = [];
|
$this->package->header->RuntimeConstants = [];
|
||||||
$this->package->header->RuntimeConstants = array_merge(
|
$this->package->header->RuntimeConstants = array_merge(
|
||||||
($selected_build_configuration->DefineConstants ?? []),
|
($selected_build_configuration->define_constants ?? []),
|
||||||
($this->project->build->define_constants ?? []),
|
($this->project->build->define_constants ?? []),
|
||||||
($this->package->header->RuntimeConstants ?? [])
|
($this->package->header->RuntimeConstants ?? [])
|
||||||
);
|
);
|
||||||
|
@ -153,9 +153,9 @@
|
||||||
// Include file components that can be compiled
|
// Include file components that can be compiled
|
||||||
$DirectoryScanner->setIncludes(ComponentFileExtensions::PHP);
|
$DirectoryScanner->setIncludes(ComponentFileExtensions::PHP);
|
||||||
|
|
||||||
if($selected_build_configuration->ExcludeFiles !== null && count($selected_build_configuration->ExcludeFiles) > 0)
|
if($selected_build_configuration->exclude_files !== null && count($selected_build_configuration->exclude_files) > 0)
|
||||||
{
|
{
|
||||||
$DirectoryScanner->setExcludes($selected_build_configuration->ExcludeFiles);
|
$DirectoryScanner->setExcludes($selected_build_configuration->exclude_files);
|
||||||
}
|
}
|
||||||
|
|
||||||
$source_path = $this->path . $this->project->build->source_path;
|
$source_path = $this->path . $this->project->build->source_path;
|
||||||
|
@ -196,9 +196,9 @@
|
||||||
$DirectoryScanner->setIncludes();
|
$DirectoryScanner->setIncludes();
|
||||||
|
|
||||||
// Ignore component files
|
// Ignore component files
|
||||||
if($selected_build_configuration->ExcludeFiles !== null && count($selected_build_configuration->ExcludeFiles) > 0)
|
if($selected_build_configuration->exclude_files !== null && count($selected_build_configuration->exclude_files) > 0)
|
||||||
{
|
{
|
||||||
$DirectoryScanner->setExcludes(array_merge($selected_build_configuration->ExcludeFiles, ComponentFileExtensions::PHP));
|
$DirectoryScanner->setExcludes(array_merge($selected_build_configuration->exclude_files, ComponentFileExtensions::PHP));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -243,9 +243,9 @@
|
||||||
$selected_dependencies = array_merge($selected_dependencies, $this->project->build->dependencies);
|
$selected_dependencies = array_merge($selected_dependencies, $this->project->build->dependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($selected_build_configuration->Dependencies !== null && count($selected_build_configuration->Dependencies) > 0)
|
if($selected_build_configuration->dependencies !== null && count($selected_build_configuration->dependencies) > 0)
|
||||||
{
|
{
|
||||||
$selected_dependencies = array_merge($selected_dependencies, $selected_build_configuration->Dependencies);
|
$selected_dependencies = array_merge($selected_dependencies, $selected_build_configuration->dependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the dependencies
|
// Process the dependencies
|
||||||
|
@ -254,7 +254,7 @@
|
||||||
$package_lock_manager = new PackageLockManager();
|
$package_lock_manager = new PackageLockManager();
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
|
|
||||||
$lib_path = $selected_build_configuration->OutputPath . DIRECTORY_SEPARATOR . 'libs';
|
$lib_path = $selected_build_configuration->output_path . DIRECTORY_SEPARATOR . 'libs';
|
||||||
if($filesystem->exists($lib_path))
|
if($filesystem->exists($lib_path))
|
||||||
{
|
{
|
||||||
$filesystem->remove($lib_path);
|
$filesystem->remove($lib_path);
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->execute->Target = null;
|
$policy->execute->target = null;
|
||||||
|
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
|
@ -83,15 +83,15 @@ namespace ncc\Classes\PhpExtension;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Constants::register($assembly->Package, $name, $value, true);
|
Constants::register($assembly->package, $name, $value, true);
|
||||||
}
|
}
|
||||||
catch (ConstantReadonlyException $e)
|
catch (ConstantReadonlyException $e)
|
||||||
{
|
{
|
||||||
trigger_error('Constant \'' . $name . '\' is readonly (' . $assembly->Package . ')', E_USER_WARNING);
|
trigger_error('Constant \'' . $name . '\' is readonly (' . $assembly->package . ')', E_USER_WARNING);
|
||||||
}
|
}
|
||||||
catch (InvalidConstantNameException $e)
|
catch (InvalidConstantNameException $e)
|
||||||
{
|
{
|
||||||
throw new ImportException('Invalid constant name \'' . $name . '\' (' . $assembly->Package . ')', $e);
|
throw new ImportException('Invalid constant name \'' . $name . '\' (' . $assembly->package . ')', $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->execute->Target = null;
|
$policy->execute->target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->execute->Target = null;
|
$policy->execute->target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->execute->Target = null;
|
$policy->execute->target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -396,11 +396,11 @@
|
||||||
Console::outDebug(sprintf('pass_thru_args=%s', implode(' ', $args)));
|
Console::outDebug(sprintf('pass_thru_args=%s', implode(' ', $args)));
|
||||||
|
|
||||||
// Handle the arguments
|
// Handle the arguments
|
||||||
if($unit->execution_policy->execute->Options !== null && count($unit->execution_policy->execute->Options) > 0)
|
if($unit->execution_policy->execute->options !== null && count($unit->execution_policy->execute->options) > 0)
|
||||||
{
|
{
|
||||||
$args = array_merge($args, $unit->execution_policy->execute->Options);
|
$args = array_merge($args, $unit->execution_policy->execute->options);
|
||||||
|
|
||||||
foreach($unit->execution_policy->execute->Options as $option)
|
foreach($unit->execution_policy->execute->options as $option)
|
||||||
{
|
{
|
||||||
$args[] = ConstantCompiler::compileRuntimeConstants($option);
|
$args[] = ConstantCompiler::compileRuntimeConstants($option);
|
||||||
}
|
}
|
||||||
|
@ -410,14 +410,14 @@
|
||||||
[PathFinder::findRunner(strtolower($unit->execution_policy->runner)), $unit->file_pointer], $args)
|
[PathFinder::findRunner(strtolower($unit->execution_policy->runner)), $unit->file_pointer], $args)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($unit->execution_policy->execute->WorkingDirectory !== null)
|
if($unit->execution_policy->execute->working_directory !== null)
|
||||||
{
|
{
|
||||||
$process->setWorkingDirectory(ConstantCompiler::compileRuntimeConstants($unit->execution_policy->execute->WorkingDirectory));
|
$process->setWorkingDirectory(ConstantCompiler::compileRuntimeConstants($unit->execution_policy->execute->working_directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->execute->Timeout !== null)
|
if($unit->execution_policy->execute->timeout !== null)
|
||||||
{
|
{
|
||||||
$process->setTimeout((float)$unit->execution_policy->execute->Timeout);
|
$process->setTimeout((float)$unit->execution_policy->execute->timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -427,12 +427,12 @@
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->execute->Silent)
|
if($unit->execution_policy->execute->silent)
|
||||||
{
|
{
|
||||||
$process->disableOutput();
|
$process->disableOutput();
|
||||||
$process->setTty(false);
|
$process->setTty(false);
|
||||||
}
|
}
|
||||||
elseif($unit->execution_policy->execute->Tty)
|
elseif($unit->execution_policy->execute->tty)
|
||||||
{
|
{
|
||||||
$process->enableOutput();
|
$process->enableOutput();
|
||||||
$process->setTty(true);
|
$process->setTty(true);
|
||||||
|
@ -460,8 +460,8 @@
|
||||||
|
|
||||||
Console::outDebug(sprintf('working_directory=%s', $process->getWorkingDirectory()));
|
Console::outDebug(sprintf('working_directory=%s', $process->getWorkingDirectory()));
|
||||||
Console::outDebug(sprintf('timeout=%s', (int)$process->getTimeout()));
|
Console::outDebug(sprintf('timeout=%s', (int)$process->getTimeout()));
|
||||||
Console::outDebug(sprintf('silent=%s', ($unit->execution_policy->execute->Silent ? 'true' : 'false')));
|
Console::outDebug(sprintf('silent=%s', ($unit->execution_policy->execute->silent ? 'true' : 'false')));
|
||||||
Console::outDebug(sprintf('tty=%s', ($unit->execution_policy->execute->Tty ? 'true' : 'false')));
|
Console::outDebug(sprintf('tty=%s', ($unit->execution_policy->execute->tty ? 'true' : 'false')));
|
||||||
Console::outDebug(sprintf('options=%s', implode(' ', $args)));
|
Console::outDebug(sprintf('options=%s', implode(' ', $args)));
|
||||||
Console::outDebug(sprintf('cmd=%s', $process->getCommandLine()));
|
Console::outDebug(sprintf('cmd=%s', $process->getCommandLine()));
|
||||||
|
|
||||||
|
@ -481,9 +481,9 @@
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->exit_handlers !== null && $unit->execution_policy->exit_handlers->Error !== null)
|
if($unit->execution_policy->exit_handlers !== null && $unit->execution_policy->exit_handlers->error !== null)
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Error);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outException(sprintf('An error occurred while executing the unit \'%s\' for \'%s\' (exit code %s)', $unit->execution_policy->name, $package, $process->getExitCode()), $e);
|
Console::outException(sprintf('An error occurred while executing the unit \'%s\' for \'%s\' (exit code %s)', $unit->execution_policy->name, $package, $process->getExitCode()), $e);
|
||||||
|
@ -495,19 +495,19 @@
|
||||||
|
|
||||||
if($unit->execution_policy->exit_handlers !== null)
|
if($unit->execution_policy->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->exit_handlers->Success !== null && $process->isSuccessful())
|
if($unit->execution_policy->exit_handlers->success !== null && $process->isSuccessful())
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Success);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->success);
|
||||||
}
|
}
|
||||||
elseif($unit->execution_policy->exit_handlers->Error !== null && $process->isSuccessful())
|
elseif($unit->execution_policy->exit_handlers->error !== null && $process->isSuccessful())
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Error);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Success, $process);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->success, $process);
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Warning, $process);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->warning, $process);
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Error, $process);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->error, $process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,26 +533,26 @@
|
||||||
|
|
||||||
if($unit === null)
|
if($unit === null)
|
||||||
{
|
{
|
||||||
throw new NoAvailableUnitsException(sprintf('No execution unit named \'%s\' is available for package \'%s\'', $unit_name, $package->assembly->Package));
|
throw new NoAvailableUnitsException(sprintf('No execution unit named \'%s\' is available for package \'%s\'', $unit_name, $package->assembly->package));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the required units
|
// Get the required units
|
||||||
$required_units = [];
|
$required_units = [];
|
||||||
if($unit->execution_policy->exit_handlers !== null)
|
if($unit->execution_policy->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
$required_unit = $unit->execution_policy?->exit_handlers?->Success?->Run;
|
$required_unit = $unit->execution_policy?->exit_handlers?->success?->run;
|
||||||
if($required_unit !== null)
|
if($required_unit !== null)
|
||||||
{
|
{
|
||||||
$required_units[] = $required_unit;
|
$required_units[] = $required_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$required_unit = $unit->execution_policy?->exit_handlers?->Warning?->Run;
|
$required_unit = $unit->execution_policy?->exit_handlers?->warning?->run;
|
||||||
if($required_unit !== null)
|
if($required_unit !== null)
|
||||||
{
|
{
|
||||||
$required_units[] = $required_unit;
|
$required_units[] = $required_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$required_unit = $unit->execution_policy?->exit_handlers?->Error?->Run;
|
$required_unit = $unit->execution_policy?->exit_handlers?->error?->run;
|
||||||
if($required_unit !== null)
|
if($required_unit !== null)
|
||||||
{
|
{
|
||||||
$required_units = $required_unit;
|
$required_units = $required_unit;
|
||||||
|
@ -560,13 +560,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install the units temporarily
|
// Install the units temporarily
|
||||||
$this->addUnit($package->assembly->Package, $package->assembly->Version, $unit, true);
|
$this->addUnit($package->assembly->package, $package->assembly->version, $unit, true);
|
||||||
foreach($required_units as $r_unit)
|
foreach($required_units as $r_unit)
|
||||||
{
|
{
|
||||||
$this->addUnit($package->assembly->Package, $package->assembly->Version, $r_unit, true);
|
$this->addUnit($package->assembly->package, $package->assembly->version, $r_unit, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->executeUnit($package->assembly->Package, $package->assembly->Version, $unit_name);
|
$this->executeUnit($package->assembly->package, $package->assembly->version, $unit_name);
|
||||||
$this->cleanTemporaryUnits();
|
$this->cleanTemporaryUnits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,28 +588,28 @@
|
||||||
*/
|
*/
|
||||||
public function handleExit(string $package, string $version, ExitHandle $exit_handler, ?Process $process=null): bool
|
public function handleExit(string $package, string $version, ExitHandle $exit_handler, ?Process $process=null): bool
|
||||||
{
|
{
|
||||||
if($exit_handler->Message !== null)
|
if($exit_handler->message !== null)
|
||||||
{
|
{
|
||||||
Console::out($exit_handler->Message);
|
Console::out($exit_handler->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($process !== null && !$exit_handler->EndProcess)
|
if($process !== null && !$exit_handler->end_process)
|
||||||
{
|
{
|
||||||
if($exit_handler->ExitCode !== $process->getExitCode())
|
if($exit_handler->exit_code !== $process->getExitCode())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($exit_handler->EndProcess)
|
elseif($exit_handler->end_process)
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('exit_code=%s', $process->getExitCode()));
|
Console::outDebug(sprintf('exit_code=%s', $process->getExitCode()));
|
||||||
exit($exit_handler->ExitCode);
|
exit($exit_handler->exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($exit_handler->Run !== null)
|
if($exit_handler->run !== null)
|
||||||
{
|
{
|
||||||
Console::outVerbose('Running unit \'' . $exit_handler->Run . '\'');
|
Console::outVerbose('Running unit \'' . $exit_handler->run . '\'');
|
||||||
$this->executeUnit($package, $version, $exit_handler->Run);
|
$this->executeUnit($package, $version, $exit_handler->run);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -137,14 +137,14 @@
|
||||||
|
|
||||||
$package = Package::load($package_path);
|
$package = Package::load($package_path);
|
||||||
|
|
||||||
if(RuntimeCache::get(sprintf('installed.%s=%s', $package->assembly->Package, $package->assembly->Version)))
|
if(RuntimeCache::get(sprintf('installed.%s=%s', $package->assembly->package, $package->assembly->version)))
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('skipping installation of %s=%s, already processed', $package->assembly->Package, $package->assembly->Version));
|
Console::outDebug(sprintf('skipping installation of %s=%s, already processed', $package->assembly->package, $package->assembly->version));
|
||||||
return $package->assembly->Package;
|
return $package->assembly->package;
|
||||||
}
|
}
|
||||||
|
|
||||||
$extension = $package->header->CompilerExtension->extension;
|
$extension = $package->header->CompilerExtension->extension;
|
||||||
$installation_paths = new InstallationPaths($this->packages_path . DIRECTORY_SEPARATOR . $package->assembly->Package . '=' . $package->assembly->Version);
|
$installation_paths = new InstallationPaths($this->packages_path . DIRECTORY_SEPARATOR . $package->assembly->package . '=' . $package->assembly->version);
|
||||||
|
|
||||||
$installer = match ($extension)
|
$installer = match ($extension)
|
||||||
{
|
{
|
||||||
|
@ -152,20 +152,20 @@
|
||||||
default => throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $extension . '\' is not supported'),
|
default => throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $extension . '\' is not supported'),
|
||||||
};
|
};
|
||||||
|
|
||||||
if($this->getPackageVersion($package->assembly->Package, $package->assembly->Version) !== null)
|
if($this->getPackageVersion($package->assembly->package, $package->assembly->version) !== null)
|
||||||
{
|
{
|
||||||
if(in_array(InstallPackageOptions::REINSTALL, $options, true))
|
if(in_array(InstallPackageOptions::REINSTALL, $options, true))
|
||||||
{
|
{
|
||||||
if($this->getPackageLockManager()?->getPackageLock()?->packageExists($package->assembly->Package, $package->assembly->Version))
|
if($this->getPackageLockManager()?->getPackageLock()?->packageExists($package->assembly->package, $package->assembly->version))
|
||||||
{
|
{
|
||||||
$this->getPackageLockManager()?->getPackageLock()?->removePackageVersion(
|
$this->getPackageLockManager()?->getPackageLock()?->removePackageVersion(
|
||||||
$package->assembly->Package, $package->assembly->Version
|
$package->assembly->package, $package->assembly->version
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new PackageAlreadyInstalledException('The package ' . $package->assembly->Package . '=' . $package->assembly->Version . ' is already installed');
|
throw new PackageAlreadyInstalledException('The package ' . $package->assembly->package . '=' . $package->assembly->version . ' is already installed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::out('Installing ' . $package->assembly->Package);
|
Console::out('Installing ' . $package->assembly->package);
|
||||||
|
|
||||||
// Four For Directory Creation, preInstall, postInstall & initData methods
|
// Four For Directory Creation, preInstall, postInstall & initData methods
|
||||||
$steps = (4 + count($package->components) + count ($package->resources) + count ($package->execution_units));
|
$steps = (4 + count($package->components) + count ($package->resources) + count ($package->execution_units));
|
||||||
|
@ -367,7 +367,7 @@
|
||||||
foreach($package->execution_units as $executionUnit)
|
foreach($package->execution_units as $executionUnit)
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('processing execution unit %s', $executionUnit->execution_policy->name));
|
Console::outDebug(sprintf('processing execution unit %s', $executionUnit->execution_policy->name));
|
||||||
$execution_pointer_manager->addUnit($package->assembly->Package, $package->assembly->Version, $executionUnit);
|
$execution_pointer_manager->addUnit($package->assembly->package, $package->assembly->version, $executionUnit);
|
||||||
++$current_steps;
|
++$current_steps;
|
||||||
Console::inlineProgressBar($current_steps, $steps);
|
Console::inlineProgressBar($current_steps, $steps);
|
||||||
}
|
}
|
||||||
|
@ -387,10 +387,10 @@
|
||||||
throw new InstallationException('Cannot create symlink, no main execution policy is defined');
|
throw new InstallationException('Cannot create symlink, no main execution policy is defined');
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outDebug(sprintf('creating symlink to %s', $package->assembly->Package));
|
Console::outDebug(sprintf('creating symlink to %s', $package->assembly->package));
|
||||||
|
|
||||||
$SymlinkManager = new SymlinkManager();
|
$SymlinkManager = new SymlinkManager();
|
||||||
$SymlinkManager->add($package->assembly->Package, $package->main_execution_policy);
|
$SymlinkManager->add($package->assembly->package, $package->main_execution_policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the post-installation stage after the installation is complete
|
// Execute the post-installation stage after the installation is complete
|
||||||
|
@ -437,14 +437,14 @@
|
||||||
if($package->header->UpdateSource !== null && $package->header->UpdateSource->repository !== null)
|
if($package->header->UpdateSource !== null && $package->header->UpdateSource->repository !== null)
|
||||||
{
|
{
|
||||||
$sources_manager = new RemoteSourcesManager();
|
$sources_manager = new RemoteSourcesManager();
|
||||||
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;
|
||||||
$defined_remote_source->type = $package->header->UpdateSource->repository->Type;
|
$defined_remote_source->type = $package->header->UpdateSource->repository->type;
|
||||||
$defined_remote_source->ssl = $package->header->UpdateSource->repository->SSL;
|
$defined_remote_source->ssl = $package->header->UpdateSource->repository->ssl;
|
||||||
|
|
||||||
$sources_manager->addRemoteSource($defined_remote_source);
|
$sources_manager->addRemoteSource($defined_remote_source);
|
||||||
}
|
}
|
||||||
|
@ -453,9 +453,9 @@
|
||||||
$this->getPackageLockManager()?->getPackageLock()?->addPackage($package, $installation_paths->getInstallationPath());
|
$this->getPackageLockManager()?->getPackageLock()?->addPackage($package, $installation_paths->getInstallationPath());
|
||||||
$this->getPackageLockManager()?->save();
|
$this->getPackageLockManager()?->save();
|
||||||
|
|
||||||
RuntimeCache::set(sprintf('installed.%s=%s', $package->assembly->Package, $package->assembly->Version), true);
|
RuntimeCache::set(sprintf('installed.%s=%s', $package->assembly->package, $package->assembly->version), true);
|
||||||
|
|
||||||
return $package->assembly->Package;
|
return $package->assembly->package;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -702,7 +702,7 @@
|
||||||
|
|
||||||
if ($dependency->source_type !== null && !$dependency_met)
|
if ($dependency->source_type !== null && !$dependency_met)
|
||||||
{
|
{
|
||||||
Console::outVerbose(sprintf('Installing dependency %s=%s for %s=%s', $dependency->name, $dependency->version, $package->assembly->Package, $package->assembly->Version));
|
Console::outVerbose(sprintf('Installing dependency %s=%s for %s=%s', $dependency->name, $dependency->version, $package->assembly->package, $package->assembly->version));
|
||||||
switch ($dependency->source_type)
|
switch ($dependency->source_type)
|
||||||
{
|
{
|
||||||
case DependencySourceType::LOCAL:
|
case DependencySourceType::LOCAL:
|
||||||
|
@ -733,7 +733,7 @@
|
||||||
}
|
}
|
||||||
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 MissingDependencyException(sprintf('The dependency %s=%s for %s=%s is not met', $dependency->name, $dependency->version, $package->assembly->package, $package->assembly->version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,7 +1024,7 @@
|
||||||
*/
|
*/
|
||||||
private static function initData(Package $package, InstallationPaths $paths): void
|
private static function initData(Package $package, InstallationPaths $paths): void
|
||||||
{
|
{
|
||||||
Console::outVerbose(sprintf('Initializing data for %s', $package->assembly->Name));
|
Console::outVerbose(sprintf('Initializing data for %s', $package->assembly->name));
|
||||||
|
|
||||||
// Create data files
|
// Create data files
|
||||||
$dependencies = [];
|
$dependencies = [];
|
||||||
|
|
|
@ -139,10 +139,10 @@
|
||||||
$this->project_configuration->project->compiler = $compiler;
|
$this->project_configuration->project->compiler = $compiler;
|
||||||
|
|
||||||
// Set the assembly information
|
// Set the assembly information
|
||||||
$this->project_configuration->assembly->Name = $name;
|
$this->project_configuration->assembly->name = $name;
|
||||||
$this->project_configuration->assembly->Package = $package;
|
$this->project_configuration->assembly->package = $package;
|
||||||
$this->project_configuration->assembly->Version = '1.0.0';
|
$this->project_configuration->assembly->version = '1.0.0';
|
||||||
$this->project_configuration->assembly->UUID = Uuid::v1()->toRfc4122();
|
$this->project_configuration->assembly->uuid = Uuid::v1()->toRfc4122();
|
||||||
|
|
||||||
// Set the build information
|
// Set the build information
|
||||||
$this->project_configuration->build->source_path = $src;
|
$this->project_configuration->build->source_path = $src;
|
||||||
|
@ -162,14 +162,14 @@
|
||||||
|
|
||||||
// Generate configurations
|
// Generate configurations
|
||||||
$DebugConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
$DebugConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
||||||
$DebugConfiguration->Name = 'debug';
|
$DebugConfiguration->name = 'debug';
|
||||||
$DebugConfiguration->OutputPath = 'build/debug';
|
$DebugConfiguration->output_path = 'build/debug';
|
||||||
$DebugConfiguration->DefineConstants["DEBUG"] = '1'; // Debugging constant if the program wishes to check for this
|
$DebugConfiguration->define_constants["DEBUG"] = '1'; // Debugging constant if the program wishes to check for this
|
||||||
$this->project_configuration->build->build_configurations[] = $DebugConfiguration;
|
$this->project_configuration->build->build_configurations[] = $DebugConfiguration;
|
||||||
$ReleaseConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
$ReleaseConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
||||||
$ReleaseConfiguration->Name = 'release';
|
$ReleaseConfiguration->name = 'release';
|
||||||
$ReleaseConfiguration->OutputPath = 'build/release';
|
$ReleaseConfiguration->output_path = 'build/release';
|
||||||
$ReleaseConfiguration->DefineConstants["DEBUG"] = '0'; // Debugging constant if the program wishes to check for this
|
$ReleaseConfiguration->define_constants["DEBUG"] = '0'; // Debugging constant if the program wishes to check for this
|
||||||
$this->project_configuration->build->build_configurations[] = $ReleaseConfiguration;
|
$this->project_configuration->build->build_configurations[] = $ReleaseConfiguration;
|
||||||
|
|
||||||
// Finally, create project.json
|
// Finally, create project.json
|
||||||
|
|
|
@ -84,24 +84,24 @@
|
||||||
*/
|
*/
|
||||||
public function addPackage(Package $package, string $install_path): void
|
public function addPackage(Package $package, string $install_path): void
|
||||||
{
|
{
|
||||||
Console::outVerbose("Adding package {$package->assembly->Package} to package lock file");
|
Console::outVerbose("Adding package {$package->assembly->package} to package lock file");
|
||||||
|
|
||||||
if(!isset($this->Packages[$package->assembly->Package]))
|
if(!isset($this->Packages[$package->assembly->package]))
|
||||||
{
|
{
|
||||||
$package_entry = new PackageEntry();
|
$package_entry = new PackageEntry();
|
||||||
$package_entry->addVersion($package, $install_path, true);
|
$package_entry->addVersion($package, $install_path, true);
|
||||||
$package_entry->Name = $package->assembly->Package;
|
$package_entry->Name = $package->assembly->package;
|
||||||
$package_entry->UpdateSource = $package->header->UpdateSource;
|
$package_entry->UpdateSource = $package->header->UpdateSource;
|
||||||
$package_entry->getDataPath();
|
$package_entry->getDataPath();
|
||||||
$this->Packages[$package->assembly->Package] = $package_entry;
|
$this->Packages[$package->assembly->package] = $package_entry;
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Packages[$package->assembly->Package]->UpdateSource = $package->header->UpdateSource;
|
$this->Packages[$package->assembly->package]->UpdateSource = $package->header->UpdateSource;
|
||||||
$this->Packages[$package->assembly->Package]->addVersion($package, $install_path, true);
|
$this->Packages[$package->assembly->package]->addVersion($package, $install_path, true);
|
||||||
$this->Packages[$package->assembly->Package]->getDataPath();
|
$this->Packages[$package->assembly->package]->getDataPath();
|
||||||
$this->update();
|
$this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,14 +154,14 @@
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ($this->getVersion($package->assembly->Version) !== null)
|
if ($this->getVersion($package->assembly->version) !== null)
|
||||||
{
|
{
|
||||||
if(!$overwrite)
|
if(!$overwrite)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->removeVersion($package->assembly->Version);
|
$this->removeVersion($package->assembly->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (VersionNotFoundException $e)
|
catch (VersionNotFoundException $e)
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = new VersionEntry();
|
$version = new VersionEntry();
|
||||||
$version->Version = $package->assembly->Version;
|
$version->Version = $package->assembly->version;
|
||||||
$version->Compiler = $package->header->CompilerExtension;
|
$version->Compiler = $package->header->CompilerExtension;
|
||||||
$version->ExecutionUnits = $package->execution_units;
|
$version->ExecutionUnits = $package->execution_units;
|
||||||
$version->MainExecutionPolicy = $package->main_execution_policy;
|
$version->MainExecutionPolicy = $package->main_execution_policy;
|
||||||
|
|
|
@ -331,44 +331,44 @@
|
||||||
if($execution_policy?->exit_handlers !== null)
|
if($execution_policy?->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
if(
|
if(
|
||||||
$execution_policy?->exit_handlers->Success !== null &&
|
$execution_policy?->exit_handlers->success !== null &&
|
||||||
$execution_policy?->exit_handlers->Success->Run !== null
|
$execution_policy?->exit_handlers->success->run !== null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(!in_array($execution_policy?->exit_handlers->Success->Run, $defined_polices, true))
|
if(!in_array($execution_policy?->exit_handlers->success->run, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Success exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->Success->Run . '\'');
|
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Success exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->success->run . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($execution_policy?->exit_handlers->Success->Run, $required_policies, true))
|
if(!in_array($execution_policy?->exit_handlers->success->run, $required_policies, true))
|
||||||
{
|
{
|
||||||
$required_policies[] = $execution_policy?->exit_handlers->Success->Run;
|
$required_policies[] = $execution_policy?->exit_handlers->success->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($execution_policy?->exit_handlers->Warning !== null && $execution_policy?->exit_handlers->Warning->Run !== null)
|
if($execution_policy?->exit_handlers->warning !== null && $execution_policy?->exit_handlers->warning->run !== null)
|
||||||
{
|
{
|
||||||
if(!in_array($execution_policy?->exit_handlers->Warning->Run, $defined_polices, true))
|
if(!in_array($execution_policy?->exit_handlers->warning->run, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Warning exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->Warning->Run . '\'');
|
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Warning exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->warning->run . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($execution_policy?->exit_handlers->Warning->Run, $required_policies, true))
|
if(!in_array($execution_policy?->exit_handlers->warning->run, $required_policies, true))
|
||||||
{
|
{
|
||||||
$required_policies[] = $execution_policy?->exit_handlers->Warning->Run;
|
$required_policies[] = $execution_policy?->exit_handlers->warning->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($execution_policy?->exit_handlers->Error !== null && $execution_policy?->exit_handlers->Error->Run !== null)
|
if($execution_policy?->exit_handlers->error !== null && $execution_policy?->exit_handlers->error->run !== null)
|
||||||
{
|
{
|
||||||
if(!in_array($execution_policy?->exit_handlers->Error->Run, $defined_polices, true))
|
if(!in_array($execution_policy?->exit_handlers->error->run, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Error exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->Error->Run . '\'');
|
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Error exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->error->run . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($execution_policy?->exit_handlers->Error->Run, $required_policies, true))
|
if(!in_array($execution_policy?->exit_handlers->error->run, $required_policies, true))
|
||||||
{
|
{
|
||||||
$required_policies[] = $execution_policy?->exit_handlers->Error->Run;
|
$required_policies[] = $execution_policy?->exit_handlers->error->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,26 +423,26 @@
|
||||||
{
|
{
|
||||||
$required_policies = [];
|
$required_policies = [];
|
||||||
|
|
||||||
if ($configuration->PreBuild !== null && count($configuration->PreBuild) > 0)
|
if ($configuration->pre_build !== null && count($configuration->pre_build) > 0)
|
||||||
{
|
{
|
||||||
foreach ($configuration->PreBuild as $unit)
|
foreach ($configuration->pre_build as $unit)
|
||||||
{
|
{
|
||||||
if (!in_array($unit, $defined_polices, true))
|
if (!in_array($unit, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The property \'pre_build\' in the build configuration \'' . $configuration->Name . '\' calls for an undefined execution policy \'' . $unit . '\'');
|
throw new UndefinedExecutionPolicyException('The property \'pre_build\' in the build configuration \'' . $configuration->name . '\' calls for an undefined execution policy \'' . $unit . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
$required_policies[] = $unit;
|
$required_policies[] = $unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($configuration->PostBuild !== null && count($configuration->PostBuild) > 0)
|
if ($configuration->post_build !== null && count($configuration->post_build) > 0)
|
||||||
{
|
{
|
||||||
foreach ($configuration->PostBuild as $unit)
|
foreach ($configuration->post_build as $unit)
|
||||||
{
|
{
|
||||||
if (!in_array($unit, $defined_polices, true))
|
if (!in_array($unit, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The property \'pre_build\' in the build configuration \'' . $configuration->Name . '\' calls for an undefined execution policy \'' . $unit . '\'');
|
throw new UndefinedExecutionPolicyException('The property \'pre_build\' in the build configuration \'' . $configuration->name . '\' calls for an undefined execution policy \'' . $unit . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
$required_policies[] = $unit;
|
$required_policies[] = $unit;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
use ncc\Enums\RegexPatterns;
|
use ncc\Enums\RegexPatterns;
|
||||||
use ncc\Exceptions\InvalidProjectConfigurationException;
|
use ncc\Exceptions\InvalidProjectConfigurationException;
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
use ncc\Utilities\Validate;
|
use ncc\Utilities\Validate;
|
||||||
|
|
||||||
|
@ -33,68 +34,68 @@
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
class Assembly
|
class Assembly implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The software name
|
* The software name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Name;
|
public $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The package name used to identify the package
|
* The package name used to identify the package
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Package;
|
public $package;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The software description
|
* The software description
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Description;
|
public $description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Company;
|
public $company;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The product name
|
* The product name
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Product;
|
public $product;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The copyright header for the product
|
* The copyright header for the product
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Copyright;
|
public $copyright;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product trademark
|
* Product trademark
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Trademark;
|
public $trademark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Software version
|
* Software version
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Version;
|
public $version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Universally Unique Identifier
|
* Universally Unique Identifier
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $UUID;
|
public $uuid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the object information to detect possible errors
|
* Validates the object information to detect possible errors
|
||||||
|
@ -105,73 +106,92 @@
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
{
|
{
|
||||||
if(!preg_match(RegexPatterns::UUID, $this->UUID))
|
if(!preg_match(RegexPatterns::UUID, $this->uuid))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The UUID is not a valid v4 UUID', 'Assembly.UUID');
|
throw new InvalidProjectConfigurationException('The UUID is not a valid v4 UUID', 'Assembly.UUID');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Version !== null && !Validate::version($this->Version))
|
if($this->version !== null && !Validate::version($this->version))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The version number is invalid', 'Assembly.Version');
|
throw new InvalidProjectConfigurationException('The version number is invalid', 'Assembly.Version');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Package !== null && !preg_match(RegexPatterns::PACKAGE_NAME_FORMAT, $this->Package))
|
if($this->package !== null && !preg_match(RegexPatterns::PACKAGE_NAME_FORMAT, $this->package))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The package name is invalid', 'Assembly.Package');
|
throw new InvalidProjectConfigurationException('The package name is invalid', 'Assembly.Package');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Name !== null && strlen($this->Name) > 126)
|
if($this->name !== null && strlen($this->name) > 126)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The name cannot be larger than 126 characters', 'Assembly.Name');
|
throw new InvalidProjectConfigurationException('The name cannot be larger than 126 characters', 'Assembly.Name');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Description !== null && strlen($this->Description) > 512)
|
if($this->description !== null && strlen($this->description) > 512)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The description cannot be larger than 512 characters', 'Assembly.Description');
|
throw new InvalidProjectConfigurationException('The description cannot be larger than 512 characters', 'Assembly.Description');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Company !== null && strlen($this->Company) > 126)
|
if($this->company !== null && strlen($this->company) > 126)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The company cannot be larger than 126 characters', 'Assembly.Company');
|
throw new InvalidProjectConfigurationException('The company cannot be larger than 126 characters', 'Assembly.Company');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Product !== null && strlen($this->Product) > 256)
|
if($this->product !== null && strlen($this->product) > 256)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The company cannot be larger than 256 characters', 'Assembly.Product');
|
throw new InvalidProjectConfigurationException('The company cannot be larger than 256 characters', 'Assembly.Product');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Copyright !== null && strlen($this->Copyright) > 256)
|
if($this->copyright !== null && strlen($this->copyright) > 256)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The copyright cannot be larger than 256 characters', 'Assembly.Copyright');
|
throw new InvalidProjectConfigurationException('The copyright cannot be larger than 256 characters', 'Assembly.Copyright');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Trademark !== null && strlen($this->Trademark) > 256)
|
if($this->trademark !== null && strlen($this->trademark) > 256)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectConfigurationException('The trademark cannot be larger than 256 characters', 'Assembly.Trademark');
|
throw new InvalidProjectConfigurationException('The trademark cannot be larger than 256 characters', 'Assembly.Trademark');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -180,65 +200,77 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$return_results = [];
|
$results = [];
|
||||||
|
|
||||||
if($this->Name !== null && strlen($this->Name) > 0)
|
if($this->name !== null && $this->name !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('name') : 'name')] = $this->Name;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('name') : 'name')] = $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Package !== null && strlen($this->Package) > 0)
|
if($this->package !== null && $this->package !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('package') : 'package')] = $this->Package;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('package') : 'package')] = $this->package;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Description !== null && strlen($this->Description) > 0)
|
if($this->description !== null && $this->description !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('description') : 'description')] = $this->Description;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('description') : 'description')] = $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Company !== null && strlen($this->Company) > 0)
|
if($this->company !== null && $this->company !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('company') : 'company')] = $this->Company;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('company') : 'company')] = $this->company;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Product !== null && strlen($this->Product) > 0)
|
if($this->product !== null && $this->product !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('product') : 'product')] = $this->Product;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('product') : 'product')] = $this->product;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Copyright !== null && strlen($this->Copyright) > 0)
|
if($this->copyright !== null && $this->copyright !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('copyright') : 'copyright')] = $this->Copyright;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('copyright') : 'copyright')] = $this->copyright;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Trademark !== null && strlen($this->Trademark) > 0)
|
if($this->trademark !== null && $this->trademark !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('trademark') : 'trademark')] = $this->Trademark;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('trademark') : 'trademark')] = $this->trademark;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Version !== null && strlen($this->Version) > 0)
|
if($this->version !== null && $this->version !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('version') : 'version')] = $this->Version;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('version') : 'version')] = $this->version;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->UUID !== null && strlen($this->UUID) > 0)
|
if($this->uuid !== null && $this->uuid !== '')
|
||||||
$return_results[($bytecode ? Functions::cbc('uuid') : 'uuid')] = $this->UUID;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('uuid') : 'uuid')] = $this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
return $return_results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return Assembly
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): Assembly
|
public static function fromArray(array $data): Assembly
|
||||||
{
|
{
|
||||||
$AssemblyObject = new Assembly();
|
$object = new self();
|
||||||
|
|
||||||
$AssemblyObject->Name = Functions::array_bc($data, 'name');
|
$object->name = Functions::array_bc($data, 'name');
|
||||||
$AssemblyObject->Package = Functions::array_bc($data, 'package');
|
$object->package = Functions::array_bc($data, 'package');
|
||||||
$AssemblyObject->Description = Functions::array_bc($data, 'description');
|
$object->description = Functions::array_bc($data, 'description');
|
||||||
$AssemblyObject->Company = Functions::array_bc($data, 'company');
|
$object->company = Functions::array_bc($data, 'company');
|
||||||
$AssemblyObject->Product = Functions::array_bc($data, 'product');
|
$object->product = Functions::array_bc($data, 'product');
|
||||||
$AssemblyObject->Copyright = Functions::array_bc($data, 'copyright');
|
$object->copyright = Functions::array_bc($data, 'copyright');
|
||||||
$AssemblyObject->Trademark = Functions::array_bc($data, 'trademark');
|
$object->trademark = Functions::array_bc($data, 'trademark');
|
||||||
$AssemblyObject->Version = Functions::array_bc($data, 'version');
|
$object->version = Functions::array_bc($data, 'version');
|
||||||
$AssemblyObject->UUID = Functions::array_bc($data, 'uuid');
|
$object->uuid = Functions::array_bc($data, 'uuid');
|
||||||
|
|
||||||
return $AssemblyObject;
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -192,11 +192,11 @@
|
||||||
$build_configurations = [];
|
$build_configurations = [];
|
||||||
foreach($this->build_configurations as $configuration)
|
foreach($this->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
if(in_array($configuration->Name, $build_configurations, true))
|
if(in_array($configuration->name, $build_configurations, true))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
throw new InvalidProjectBuildConfiguration('The build configuration \'' . $configuration->Name . '\' is already defined, build configuration names must be unique');
|
throw new InvalidProjectBuildConfiguration('The build configuration \'' . $configuration->name . '\' is already defined, build configuration names must be unique');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -214,7 +214,7 @@
|
||||||
}
|
}
|
||||||
catch (InvalidBuildConfigurationException $e)
|
catch (InvalidBuildConfigurationException $e)
|
||||||
{
|
{
|
||||||
throw new InvalidBuildConfigurationException(sprintf('Error in build configuration \'%s\'', $configuration->Name), $e);
|
throw new InvalidBuildConfigurationException(sprintf('Error in build configuration \'%s\'', $configuration->name), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@
|
||||||
|
|
||||||
foreach($this->build_configurations as $configuration)
|
foreach($this->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
$build_configurations[] = $configuration->Name;
|
$build_configurations[] = $configuration->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $build_configurations;
|
return $build_configurations;
|
||||||
|
@ -278,7 +278,7 @@
|
||||||
|
|
||||||
foreach($this->build_configurations as $configuration)
|
foreach($this->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
if($configuration->Name === $name)
|
if($configuration->name === $name)
|
||||||
{
|
{
|
||||||
return $configuration;
|
return $configuration;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
use ncc\Exceptions\InvalidBuildConfigurationException;
|
use ncc\Exceptions\InvalidBuildConfigurationException;
|
||||||
use ncc\Exceptions\InvalidDependencyConfiguration;
|
use ncc\Exceptions\InvalidDependencyConfiguration;
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Objects\ProjectConfiguration\Dependency;
|
use ncc\Objects\ProjectConfiguration\Dependency;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
use ncc\Utilities\Validate;
|
use ncc\Utilities\Validate;
|
||||||
|
@ -34,56 +35,56 @@
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
class BuildConfiguration
|
class BuildConfiguration implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The unique name of the build configuration
|
* The unique name of the build configuration
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Name;
|
public $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options to pass onto the extension compiler
|
* Options to pass onto the extension compiler
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $Options;
|
public $options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The build output path for the build configuration, eg; build/%BUILD.NAME%
|
* The build output path for the build configuration, eg; build/%BUILD.NAME%
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $OutputPath;
|
public $output_path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of constants to define for the build when importing or executing.
|
* An array of constants to define for the build when importing or executing.
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $DefineConstants;
|
public $define_constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of files to exclude in this build configuration
|
* An array of files to exclude in this build configuration
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $ExcludeFiles;
|
public $exclude_files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of policies to execute pre-building the package
|
* An array of policies to execute pre-building the package
|
||||||
*
|
*
|
||||||
* @var string[]|string
|
* @var string[]|string
|
||||||
*/
|
*/
|
||||||
public $PreBuild;
|
public $pre_build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of policies to execute post-building the package
|
* An array of policies to execute post-building the package
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $PostBuild;
|
public $post_build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dependencies required for the build configuration, cannot conflict with the
|
* Dependencies required for the build configuration, cannot conflict with the
|
||||||
|
@ -91,20 +92,20 @@
|
||||||
*
|
*
|
||||||
* @var Dependency[]
|
* @var Dependency[]
|
||||||
*/
|
*/
|
||||||
public $Dependencies;
|
public $dependencies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Constructor
|
* Public Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->Options = [];
|
$this->options = [];
|
||||||
$this->OutputPath = 'build';
|
$this->output_path = 'build';
|
||||||
$this->DefineConstants = [];
|
$this->define_constants = [];
|
||||||
$this->ExcludeFiles = [];
|
$this->exclude_files = [];
|
||||||
$this->PreBuild = [];
|
$this->pre_build = [];
|
||||||
$this->PostBuild = [];
|
$this->post_build = [];
|
||||||
$this->Dependencies = [];
|
$this->dependencies = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,74 +117,92 @@
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
{
|
{
|
||||||
if(!Validate::nameFriendly($this->Name))
|
if(!Validate::nameFriendly($this->name))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('Invalid build configuration name "%s"', $this->Name));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('Invalid build configuration name "%s"', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Validate::pathName($this->OutputPath))
|
if(!Validate::pathName($this->output_path))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('\'output_path\' contains an invalid path name in %s', $this->Name));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('\'output_path\' contains an invalid path name in %s', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->DefineConstants !== null && !is_array($this->DefineConstants))
|
if($this->define_constants !== null && !is_array($this->define_constants))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('\'define_constants\' must be an array in %s', $this->Name));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('\'define_constants\' must be an array in %s', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->ExcludeFiles !== null && !is_array($this->ExcludeFiles))
|
if($this->exclude_files !== null && !is_array($this->exclude_files))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('\'exclude_files\' must be an array in %s', $this->Name));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('\'exclude_files\' must be an array in %s', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->PreBuild !== null && !is_array($this->PreBuild))
|
if($this->pre_build !== null && !is_array($this->pre_build))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('\'pre_build\' must be an array in %s', $this->Name));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('\'pre_build\' must be an array in %s', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->PostBuild !== null && !is_array($this->PostBuild))
|
if($this->post_build !== null && !is_array($this->post_build))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('\'post_build\' must be an array in %s', $this->Name));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('\'post_build\' must be an array in %s', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Dependencies !== null && !is_array($this->Dependencies))
|
if($this->dependencies !== null && !is_array($this->dependencies))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('\'dependencies\' must be an array in %s', $this->Name));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('\'dependencies\' must be an array in %s', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Dependency $dependency */
|
/** @var Dependency $dependency */
|
||||||
foreach($this->Dependencies as $dependency)
|
foreach($this->dependencies as $dependency)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!$dependency->validate($throw_exception))
|
if (!$dependency->validate($throw_exception))
|
||||||
|
{
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (InvalidDependencyConfiguration $e)
|
catch (InvalidDependencyConfiguration $e)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidBuildConfigurationException(sprintf('Invalid dependency configuration in %s: %s', $this->Name, $e->getMessage()));
|
{
|
||||||
|
throw new InvalidBuildConfigurationException(sprintf('Invalid dependency configuration in %s: %s', $this->name, $e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
@ -193,64 +212,78 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param boolean $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$ReturnResults = [];
|
$results = [];
|
||||||
|
|
||||||
if($this->Name !== null && strlen($this->Name) > 0)
|
if($this->name !== null && $this->name !== '')
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('name') : 'name')] = $this->Name;
|
|
||||||
if($this->Options !== null && count($this->Options) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options;
|
|
||||||
if($this->OutputPath !== null && strlen($this->OutputPath) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('output_path') : 'output_path')] = $this->OutputPath;
|
|
||||||
if($this->DefineConstants !== null && count($this->DefineConstants) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('define_constants') : 'define_constants')] = $this->DefineConstants;
|
|
||||||
if($this->ExcludeFiles !== null && count($this->ExcludeFiles) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('exclude_files') : 'exclude_files')] = $this->ExcludeFiles;
|
|
||||||
if($this->PreBuild !== null && count($this->PreBuild) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('pre_build') : 'pre_build')] = $this->PreBuild;
|
|
||||||
if($this->Dependencies !== null && count($this->Dependencies) > 0)
|
|
||||||
{
|
{
|
||||||
$Dependencies = [];
|
$results[($bytecode ? Functions::cbc('name') : 'name')] = $this->name;
|
||||||
foreach($this->Dependencies as $Dependency)
|
|
||||||
{
|
|
||||||
$Dependencies[] = $Dependency->toArray($bytecode);
|
|
||||||
}
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('dependencies') : 'dependencies')] = $Dependencies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ReturnResults;
|
if($this->options !== null && count($this->options) > 0)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('options') : 'options')] = $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->output_path !== null && $this->output_path !== '')
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('output_path') : 'output_path')] = $this->output_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->define_constants !== null && count($this->define_constants) > 0)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('define_constants') : 'define_constants')] = $this->define_constants;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->exclude_files !== null && count($this->exclude_files) > 0)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('exclude_files') : 'exclude_files')] = $this->exclude_files;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->pre_build !== null && count($this->pre_build) > 0)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('pre_build') : 'pre_build')] = $this->pre_build;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->dependencies !== null && count($this->dependencies) > 0)
|
||||||
|
{
|
||||||
|
$dependencies = array_map(static function(Dependency $Dependency) use ($bytecode)
|
||||||
|
{
|
||||||
|
return $Dependency->toArray($bytecode);
|
||||||
|
}, $this->dependencies);
|
||||||
|
|
||||||
|
$results[($bytecode ? Functions::cbc('dependencies') : 'dependencies')] = $dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return BuildConfiguration
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): BuildConfiguration
|
public static function fromArray(array $data): BuildConfiguration
|
||||||
{
|
{
|
||||||
$BuildConfigurationObject = new BuildConfiguration();
|
$object = new BuildConfiguration();
|
||||||
|
|
||||||
$BuildConfigurationObject->Name = Functions::array_bc($data, 'name');
|
$object->name = Functions::array_bc($data, 'name');
|
||||||
$BuildConfigurationObject->Options = Functions::array_bc($data, 'options');
|
$object->options = Functions::array_bc($data, 'options');
|
||||||
$BuildConfigurationObject->OutputPath = Functions::array_bc($data, 'output_path');
|
$object->output_path = Functions::array_bc($data, 'output_path');
|
||||||
$BuildConfigurationObject->DefineConstants = Functions::array_bc($data, 'define_constants');
|
$object->define_constants = Functions::array_bc($data, 'define_constants');
|
||||||
$BuildConfigurationObject->ExcludeFiles = Functions::array_bc($data, 'exclude_files');
|
$object->exclude_files = Functions::array_bc($data, 'exclude_files');
|
||||||
$BuildConfigurationObject->PreBuild = Functions::array_bc($data, 'pre_build');
|
$object->pre_build = Functions::array_bc($data, 'pre_build');
|
||||||
$BuildConfigurationObject->PostBuild = Functions::array_bc($data, 'post_build');
|
$object->post_build = Functions::array_bc($data, 'post_build');
|
||||||
|
|
||||||
if(Functions::array_bc($data, 'dependencies') !== null)
|
if(Functions::array_bc($data, 'dependencies') !== null)
|
||||||
{
|
{
|
||||||
foreach(Functions::array_bc($data, 'dependencies') as $item)
|
foreach(Functions::array_bc($data, 'dependencies') as $item)
|
||||||
$BuildConfigurationObject->Dependencies[] = Dependency::fromArray($item);
|
{
|
||||||
|
$object->dependencies[] = Dependency::fromArray($item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $BuildConfigurationObject;
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,16 +24,17 @@
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
|
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
|
||||||
|
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class Execute
|
class Execute implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The target file to execute
|
* The target file to execute
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Target;
|
public $target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The working directory to execute the policy in, if not specified the
|
* The working directory to execute the policy in, if not specified the
|
||||||
|
@ -41,35 +42,35 @@
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $WorkingDirectory;
|
public $working_directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options to pass to the process
|
* Options to pass to the process
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $Options;
|
public $options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of environment variables to pass on to the process
|
* An array of environment variables to pass on to the process
|
||||||
*
|
*
|
||||||
* @var array|null
|
* @var array|null
|
||||||
*/
|
*/
|
||||||
public $EnvironmentVariables;
|
public $environment_variables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the output should be displayed or suppressed
|
* Indicates if the output should be displayed or suppressed
|
||||||
*
|
*
|
||||||
* @var bool|null
|
* @var bool|null
|
||||||
*/
|
*/
|
||||||
public $Silent;
|
public $silent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the process should run in Tty mode (Overrides Silent & Pty mode)
|
* Indicates if the process should run in Tty mode (Overrides Silent & Pty mode)
|
||||||
*
|
*
|
||||||
* @var bool|null
|
* @var bool|null
|
||||||
*/
|
*/
|
||||||
public $Tty;
|
public $tty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of seconds to wait before giving up on the process, will automatically execute the error handler
|
* The number of seconds to wait before giving up on the process, will automatically execute the error handler
|
||||||
|
@ -77,80 +78,90 @@
|
||||||
*
|
*
|
||||||
* @var int|null
|
* @var int|null
|
||||||
*/
|
*/
|
||||||
public $Timeout;
|
public $timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int|null
|
* @var int|null
|
||||||
*/
|
*/
|
||||||
public $IdleTimeout;
|
public $idle_timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Constructor
|
* Public Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->Tty = false;
|
$this->tty = false;
|
||||||
$this->Silent = false;
|
$this->silent = false;
|
||||||
$this->Timeout = null;
|
$this->timeout = null;
|
||||||
$this->IdleTimeout = null;
|
$this->idle_timeout = null;
|
||||||
$this->WorkingDirectory = "%CWD%";
|
$this->working_directory = "%CWD%";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
if($this->Target !== null)
|
if($this->target !== null)
|
||||||
$results[($bytecode ? Functions::cbc("target") : "target")] = $this->Target;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('target') : 'target')] = $this->target;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->WorkingDirectory !== null)
|
if($this->working_directory !== null)
|
||||||
$results[($bytecode ? Functions::cbc("working_directory") : "working_directory")] = $this->WorkingDirectory;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('working_directory') : 'working_directory')] = $this->working_directory;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Options !== null)
|
if($this->options !== null)
|
||||||
$results[($bytecode ? Functions::cbc("options") : "options")] = $this->Options;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('options') : 'options')] = $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->EnvironmentVariables !== null)
|
if($this->environment_variables !== null)
|
||||||
$results[($bytecode ? Functions::cbc("environment_variables") : "environment_variables")] = $this->EnvironmentVariables;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('environment_variables') : 'environment_variables')] = $this->environment_variables;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Silent !== null)
|
if($this->silent !== null)
|
||||||
$results[($bytecode ? Functions::cbc("silent") : "silent")] = (bool)$this->Silent;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('silent') : 'silent')] = (bool)$this->silent;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Tty !== null)
|
if($this->tty !== null)
|
||||||
$results[($bytecode ? Functions::cbc("tty") : "tty")] = (bool)$this->Tty;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('tty') : 'tty')] = (bool)$this->tty;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Timeout !== null)
|
if($this->timeout !== null)
|
||||||
$results[($bytecode ? Functions::cbc("timeout") : "timeout")] = (int)$this->Timeout;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('timeout') : 'timeout')] = (int)$this->timeout;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->IdleTimeout !== null)
|
if($this->idle_timeout !== null)
|
||||||
$results[($bytecode ? Functions::cbc("idle_timeout") : "idle_timeout")] = (int)$this->IdleTimeout;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('idle_timeout') : 'idle_timeout')] = (int)$this->idle_timeout;
|
||||||
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return Execute
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(array $data): Execute
|
||||||
{
|
{
|
||||||
$object = new self();
|
$object = new self();
|
||||||
|
|
||||||
$object->Target = Functions::array_bc($data, 'target');
|
$object->target = Functions::array_bc($data, 'target');
|
||||||
$object->WorkingDirectory = Functions::array_bc($data, 'working_directory');
|
$object->working_directory = Functions::array_bc($data, 'working_directory');
|
||||||
$object->Options = Functions::array_bc($data, 'options');
|
$object->options = Functions::array_bc($data, 'options');
|
||||||
$object->EnvironmentVariables = Functions::array_bc($data, 'environment_variables');
|
$object->environment_variables = Functions::array_bc($data, 'environment_variables');
|
||||||
$object->Silent = Functions::array_bc($data, 'silent');
|
$object->silent = Functions::array_bc($data, 'silent');
|
||||||
$object->Tty = Functions::array_bc($data, 'tty');
|
$object->tty = Functions::array_bc($data, 'tty');
|
||||||
$object->Timeout = Functions::array_bc($data, 'timeout');
|
$object->timeout = Functions::array_bc($data, 'timeout');
|
||||||
$object->IdleTimeout = Functions::array_bc($data, 'idle_timeout');
|
$object->idle_timeout = Functions::array_bc($data, 'idle_timeout');
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,17 @@
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
|
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
|
||||||
|
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class ExitHandle
|
class ExitHandle implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The message to display when the handle is triggered
|
* The message to display when the handle is triggered
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Message;
|
public $message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the process should exit if the handle is triggered,
|
* Indicates if the process should exit if the handle is triggered,
|
||||||
|
@ -44,61 +45,61 @@
|
||||||
*
|
*
|
||||||
* @var bool|null
|
* @var bool|null
|
||||||
*/
|
*/
|
||||||
public $EndProcess;
|
public $end_process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of another execution policy to execute (optionally) when this exit handle is triggered
|
* The name of another execution policy to execute (optionally) when this exit handle is triggered
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Run;
|
public $run;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exit code that needs to be returned from the process to trigger this handle
|
* The exit code that needs to be returned from the process to trigger this handle
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $ExitCode;
|
public $exit_code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$return_results = [];
|
$results = [];
|
||||||
|
|
||||||
if($this->Message !== null)
|
if($this->message !== null)
|
||||||
$return_results[($bytecode ? Functions::cbc('message') : 'message')] = $this->Message;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('message') : 'message')] = $this->message;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->EndProcess !== null)
|
if($this->end_process !== null)
|
||||||
$return_results[($bytecode ? Functions::cbc('end_process') : 'end_process')] = $this->EndProcess;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('end_process') : 'end_process')] = $this->end_process;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->Run !== null)
|
if($this->run !== null)
|
||||||
$return_results[($bytecode ? Functions::cbc('run') : 'run')] = $this->Run;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('run') : 'run')] = $this->run;
|
||||||
|
}
|
||||||
|
|
||||||
/** @noinspection PhpCastIsUnnecessaryInspection */
|
/** @noinspection PhpCastIsUnnecessaryInspection */
|
||||||
$return_results[($bytecode ? Functions::cbc('exit_code') : 'exit_code')] = (int)$this->ExitCode;
|
$results[($bytecode ? Functions::cbc('exit_code') : 'exit_code')] = (int)$this->exit_code;
|
||||||
|
|
||||||
return $return_results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return ExitHandle
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(array $data): ExitHandle
|
||||||
{
|
{
|
||||||
$object = new self();
|
$object = new self();
|
||||||
|
|
||||||
$object->Message = Functions::array_bc($data, 'message');
|
$object->message = Functions::array_bc($data, 'message');
|
||||||
$object->EndProcess = Functions::array_bc($data, 'end_process');
|
$object->end_process = Functions::array_bc($data, 'end_process');
|
||||||
$object->Run = Functions::array_bc($data, 'run');
|
$object->run = Functions::array_bc($data, 'run');
|
||||||
$object->ExitCode = Functions::array_bc($data, 'exit_code');
|
$object->exit_code = Functions::array_bc($data, 'exit_code');
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,67 +24,68 @@
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
|
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
|
||||||
|
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class ExitHandlers
|
class ExitHandlers implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The handle to execute when the process exits with a success exit code
|
* The handle to execute when the process exits with a success exit code
|
||||||
*
|
*
|
||||||
* @var ExitHandle
|
* @var ExitHandle|null
|
||||||
*/
|
*/
|
||||||
public $Success;
|
public $success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The handle to execute when the process exits with a warning exit code
|
* The handle to execute when the process exits with a warning exit code
|
||||||
*
|
*
|
||||||
* @var ExitHandle
|
* @var ExitHandle|null
|
||||||
*/
|
*/
|
||||||
public $Warning;
|
public $warning;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The handle to execute when the process exits with a error exit code
|
* The handle to execute when the process exits with a error exit code
|
||||||
*
|
*
|
||||||
* @var ExitHandle
|
* @var ExitHandle|null
|
||||||
*/
|
*/
|
||||||
public $Error;
|
public $error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
($bytecode ? Functions::cbc('success') : 'success') => $this->Success?->toArray($bytecode),
|
($bytecode ? Functions::cbc('success') : 'success') => $this->success?->toArray($bytecode),
|
||||||
($bytecode ? Functions::cbc('warning') : 'warning') => $this->Warning?->toArray($bytecode),
|
($bytecode ? Functions::cbc('warning') : 'warning') => $this->warning?->toArray($bytecode),
|
||||||
($bytecode ? Functions::cbc('error') : 'error') => $this->Error?->toArray($bytecode),
|
($bytecode ? Functions::cbc('error') : 'error') => $this->error?->toArray($bytecode),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return ExitHandlers
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(array $data): self
|
||||||
{
|
{
|
||||||
$object = new self();
|
$object = new self();
|
||||||
|
|
||||||
$object->Success = Functions::array_bc($data, 'success');
|
$object->success = Functions::array_bc($data, 'success');
|
||||||
if($object->Success !== null)
|
if($object->success !== null)
|
||||||
$object->Success = ExitHandle::fromArray($object->Success);
|
{
|
||||||
|
$object->success = ExitHandle::fromArray($object->success);
|
||||||
|
}
|
||||||
|
|
||||||
$object->Warning = Functions::array_bc($data, 'warning');
|
$object->warning = Functions::array_bc($data, 'warning');
|
||||||
if($object->Warning !== null)
|
if($object->warning !== null)
|
||||||
$object->Warning = ExitHandle::fromArray($object->Warning);
|
{
|
||||||
|
$object->warning = ExitHandle::fromArray($object->warning);
|
||||||
|
}
|
||||||
|
|
||||||
$object->Error = Functions::array_bc($data, 'error');
|
$object->error = Functions::array_bc($data, 'error');
|
||||||
if($object->Error !== null)
|
if($object->error !== null)
|
||||||
$object->Error = ExitHandle::fromArray($object->Error);
|
{
|
||||||
|
$object->error = ExitHandle::fromArray($object->error);
|
||||||
|
}
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,67 +24,64 @@
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration\UpdateSource;
|
namespace ncc\Objects\ProjectConfiguration\UpdateSource;
|
||||||
|
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class Repository
|
class Repository implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name of the remote source to add
|
* The name of the remote source to add
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Name;
|
public $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of client that is used to connect to the remote source
|
* The type of client that is used to connect to the remote source
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Type;
|
public $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The host of the remote source
|
* The host of the remote source
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Host;
|
public $host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If SSL should be used
|
* If SSL should be used
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $SSL;
|
public $ssl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
($bytecode ? Functions::cbc('name') : 'name') => $this->Name,
|
($bytecode ? Functions::cbc('name') : 'name') => $this->name,
|
||||||
($bytecode ? Functions::cbc('type') : 'type') => $this->Type,
|
($bytecode ? Functions::cbc('type') : 'type') => $this->type,
|
||||||
($bytecode ? Functions::cbc('host') : 'host') => $this->Host,
|
($bytecode ? Functions::cbc('host') : 'host') => $this->host,
|
||||||
($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->SSL
|
($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->ssl
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return Repository
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(array $data): Repository
|
||||||
{
|
{
|
||||||
$obj = new self();
|
$object = new self();
|
||||||
$obj->Name = Functions::array_bc($data, 'name');
|
|
||||||
$obj->Type = Functions::array_bc($data, 'type');
|
$object->name = Functions::array_bc($data, 'name');
|
||||||
$obj->Host = Functions::array_bc($data, 'host');
|
$object->type = Functions::array_bc($data, 'type');
|
||||||
$obj->SSL = Functions::array_bc($data, 'ssl');
|
$object->host = Functions::array_bc($data, 'host');
|
||||||
return $obj;
|
$object->ssl = Functions::array_bc($data, 'ssl');
|
||||||
|
|
||||||
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue