- 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:
Netkas 2023-08-19 12:24:42 -04:00
parent 15fd06d2d0
commit 348ca2d4a1
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
27 changed files with 651 additions and 570 deletions

View file

@ -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 > Compiler`
- 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 `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`

View file

@ -448,49 +448,49 @@
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);
@ -570,7 +570,7 @@
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)
@ -578,7 +578,7 @@
try
{
$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)
{

View file

@ -46,7 +46,7 @@ namespace ncc\Classes\BashExtension;
$execution_unit->execution_policy = $policy;
$execution_unit->Data = IO::fread($path);
$policy->execute->Target = null;
$policy->execute->target = null;
return $execution_unit;
}

View file

@ -259,10 +259,10 @@ namespace ncc\Classes\ComposerExtension;
$built_package = $project_manager->build();
// 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->remove($built_package);
$built_packages[$project_configuration->assembly->Package] = $out_path;
$built_packages[$project_configuration->assembly->package] = $out_path;
}
return $built_packages;
@ -340,27 +340,27 @@ namespace ncc\Classes\ComposerExtension;
if (isset($composer_package->Name))
{
$project_configuration->assembly->Name = $composer_package->Name;
$project_configuration->assembly->name = $composer_package->Name;
}
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]))
{
$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->Package = self::toPackageName($composer_package->Name);
$project_configuration->assembly->uuid = Uuid::v1()->toRfc4122();
$project_configuration->assembly->package = self::toPackageName($composer_package->Name);
// Add the update source
$project_configuration->project->update_source = new ProjectConfiguration\UpdateSource();
@ -391,8 +391,8 @@ namespace ncc\Classes\ComposerExtension;
// Create a build configuration
$build_configuration = new ProjectConfiguration\Build\BuildConfiguration();
$build_configuration->Name = 'default';
$build_configuration->OutputPath = 'build';
$build_configuration->name = 'default';
$build_configuration->output_path = 'build';
// Apply the final properties
$project_configuration->build->build_configurations[] = $build_configuration;

View file

@ -36,7 +36,7 @@ namespace ncc\Classes\LuaExtension;
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
{
$execution_unit = new ExecutionUnit();
$policy->execute->Target = null;
$policy->execute->target = null;
$execution_unit->execution_policy = $policy;
$execution_unit->Data = IO::fread($path);

View file

@ -46,49 +46,49 @@ namespace ncc\Classes\NccExtension;
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;

View file

@ -96,8 +96,8 @@
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $configuration->project->compiler->extension . '\' is not supported');
}
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->Name;
Console::out(sprintf('Building %s=%s', $configuration->assembly->Package, $configuration->assembly->Version));
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->name;
Console::out(sprintf('Building %s=%s', $configuration->assembly->package, $configuration->assembly->version));
$Compiler->prepare($build_configuration);
$Compiler->build();
@ -128,7 +128,7 @@
elseif($project_type->ProjectType === ProjectType::NCC)
{
$project_manager = new ProjectManager($project_type->ProjectPath);
$project_manager->getProjectConfiguration()->assembly->Version = $version;
$project_manager->getProjectConfiguration()->assembly->version = $version;
$project_path = $project_manager->build();
}
else
@ -139,7 +139,7 @@
if($version !== null)
{
$package = Package::load($project_path);
$package->assembly->Version = Functions::convertToSemVer($version);
$package->assembly->version = Functions::convertToSemVer($version);
$package->save($project_path);
}
@ -186,7 +186,7 @@
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);
}
@ -216,15 +216,15 @@
// Write the package to disk
$FileSystem = new Filesystem();
$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));
$FileSystem->mkdir($path . $BuildConfiguration->OutputPath);
Console::outDebug(sprintf('creating output directory %s', $path . $BuildConfiguration->output_path));
$FileSystem->mkdir($path . $BuildConfiguration->output_path);
}
// Finally write the package to the disk
$FileSystem->mkdir($path . $BuildConfiguration->OutputPath);
$output_file = $path . $BuildConfiguration->OutputPath . DIRECTORY_SEPARATOR . $package->assembly->Package . '.ncc';
$FileSystem->mkdir($path . $BuildConfiguration->output_path);
$output_file = $path . $BuildConfiguration->output_path . DIRECTORY_SEPARATOR . $package->assembly->package . '.ncc';
if($FileSystem->exists($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->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->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 = [];
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);
}
$unit->execution_policy->execute->Options = $options;
$unit->execution_policy->execute->options = $options;
}
}

View file

@ -45,7 +45,7 @@
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
{
$execution_unit = new ExecutionUnit();
$policy->execute->Target = null;
$policy->execute->target = null;
if(!file_exists($path) && !is_file($path))
{

View file

@ -121,7 +121,7 @@
// Global constants are overridden
$this->package->header->RuntimeConstants = [];
$this->package->header->RuntimeConstants = array_merge(
($selected_build_configuration->DefineConstants ?? []),
($selected_build_configuration->define_constants ?? []),
($this->project->build->define_constants ?? []),
($this->package->header->RuntimeConstants ?? [])
);
@ -153,9 +153,9 @@
// Include file components that can be compiled
$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;
@ -196,9 +196,9 @@
$DirectoryScanner->setIncludes();
// 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
{
@ -243,9 +243,9 @@
$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
@ -254,7 +254,7 @@
$package_lock_manager = new PackageLockManager();
$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))
{
$filesystem->remove($lib_path);

View file

@ -48,7 +48,7 @@
throw new PathNotFoundException($path);
}
$policy->execute->Target = null;
$policy->execute->target = null;
$execution_unit->execution_policy = $policy;
$execution_unit->Data = IO::fread($path);

View file

@ -83,15 +83,15 @@ namespace ncc\Classes\PhpExtension;
try
{
Constants::register($assembly->Package, $name, $value, true);
Constants::register($assembly->package, $name, $value, true);
}
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)
{
throw new ImportException('Invalid constant name \'' . $name . '\' (' . $assembly->Package . ')', $e);
throw new ImportException('Invalid constant name \'' . $name . '\' (' . $assembly->package . ')', $e);
}
}
}

View file

@ -51,7 +51,7 @@
throw new PathNotFoundException($path);
}
$policy->execute->Target = null;
$policy->execute->target = null;
$execution_unit->execution_policy = $policy;
$execution_unit->Data = IO::fread($path);

View file

@ -51,7 +51,7 @@
throw new PathNotFoundException($path);
}
$policy->execute->Target = null;
$policy->execute->target = null;
$execution_unit->execution_policy = $policy;
$execution_unit->Data = IO::fread($path);

View file

@ -51,7 +51,7 @@
throw new PathNotFoundException($path);
}
$policy->execute->Target = null;
$policy->execute->target = null;
$execution_unit->execution_policy = $policy;
$execution_unit->Data = IO::fread($path);

View file

@ -396,11 +396,11 @@
Console::outDebug(sprintf('pass_thru_args=%s', implode(' ', $args)));
// 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);
}
@ -410,14 +410,14 @@
[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
{
@ -427,12 +427,12 @@
try
{
if($unit->execution_policy->execute->Silent)
if($unit->execution_policy->execute->silent)
{
$process->disableOutput();
$process->setTty(false);
}
elseif($unit->execution_policy->execute->Tty)
elseif($unit->execution_policy->execute->tty)
{
$process->enableOutput();
$process->setTty(true);
@ -460,8 +460,8 @@
Console::outDebug(sprintf('working_directory=%s', $process->getWorkingDirectory()));
Console::outDebug(sprintf('timeout=%s', (int)$process->getTimeout()));
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('silent=%s', ($unit->execution_policy->execute->silent ? 'true' : 'false')));
Console::outDebug(sprintf('tty=%s', ($unit->execution_policy->execute->tty ? 'true' : 'false')));
Console::outDebug(sprintf('options=%s', implode(' ', $args)));
Console::outDebug(sprintf('cmd=%s', $process->getCommandLine()));
@ -481,9 +481,9 @@
}
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);
@ -495,19 +495,19 @@
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
{
$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->Error, $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->error, $process);
}
}
@ -533,26 +533,26 @@
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
$required_units = [];
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)
{
$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)
{
$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)
{
$required_units = $required_unit;
@ -560,13 +560,13 @@
}
// 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)
{
$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();
}
@ -588,28 +588,28 @@
*/
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;
}
}
elseif($exit_handler->EndProcess)
elseif($exit_handler->end_process)
{
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 . '\'');
$this->executeUnit($package, $version, $exit_handler->Run);
Console::outVerbose('Running unit \'' . $exit_handler->run . '\'');
$this->executeUnit($package, $version, $exit_handler->run);
}
return true;

View file

@ -137,14 +137,14 @@
$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));
return $package->assembly->Package;
Console::outDebug(sprintf('skipping installation of %s=%s, already processed', $package->assembly->package, $package->assembly->version));
return $package->assembly->package;
}
$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)
{
@ -152,20 +152,20 @@
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($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(
$package->assembly->Package, $package->assembly->Version
$package->assembly->package, $package->assembly->version
);
}
}
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
$steps = (4 + count($package->components) + count ($package->resources) + count ($package->execution_units));
@ -367,7 +367,7 @@
foreach($package->execution_units as $executionUnit)
{
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;
Console::inlineProgressBar($current_steps, $steps);
}
@ -387,10 +387,10 @@
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->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
@ -437,14 +437,14 @@
if($package->header->UpdateSource !== null && $package->header->UpdateSource->repository !== null)
{
$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->name = $package->header->UpdateSource->repository->Name;
$defined_remote_source->host = $package->header->UpdateSource->repository->Host;
$defined_remote_source->type = $package->header->UpdateSource->repository->Type;
$defined_remote_source->ssl = $package->header->UpdateSource->repository->SSL;
$defined_remote_source->name = $package->header->UpdateSource->repository->name;
$defined_remote_source->host = $package->header->UpdateSource->repository->host;
$defined_remote_source->type = $package->header->UpdateSource->repository->type;
$defined_remote_source->ssl = $package->header->UpdateSource->repository->ssl;
$sources_manager->addRemoteSource($defined_remote_source);
}
@ -453,9 +453,9 @@
$this->getPackageLockManager()?->getPackageLock()?->addPackage($package, $installation_paths->getInstallationPath());
$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)
{
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)
{
case DependencySourceType::LOCAL:
@ -733,7 +733,7 @@
}
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
{
Console::outVerbose(sprintf('Initializing data for %s', $package->assembly->Name));
Console::outVerbose(sprintf('Initializing data for %s', $package->assembly->name));
// Create data files
$dependencies = [];

View file

@ -139,10 +139,10 @@
$this->project_configuration->project->compiler = $compiler;
// Set the assembly information
$this->project_configuration->assembly->Name = $name;
$this->project_configuration->assembly->Package = $package;
$this->project_configuration->assembly->Version = '1.0.0';
$this->project_configuration->assembly->UUID = Uuid::v1()->toRfc4122();
$this->project_configuration->assembly->name = $name;
$this->project_configuration->assembly->package = $package;
$this->project_configuration->assembly->version = '1.0.0';
$this->project_configuration->assembly->uuid = Uuid::v1()->toRfc4122();
// Set the build information
$this->project_configuration->build->source_path = $src;
@ -162,14 +162,14 @@
// Generate configurations
$DebugConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
$DebugConfiguration->Name = 'debug';
$DebugConfiguration->OutputPath = 'build/debug';
$DebugConfiguration->DefineConstants["DEBUG"] = '1'; // Debugging constant if the program wishes to check for this
$DebugConfiguration->name = 'debug';
$DebugConfiguration->output_path = 'build/debug';
$DebugConfiguration->define_constants["DEBUG"] = '1'; // Debugging constant if the program wishes to check for this
$this->project_configuration->build->build_configurations[] = $DebugConfiguration;
$ReleaseConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
$ReleaseConfiguration->Name = 'release';
$ReleaseConfiguration->OutputPath = 'build/release';
$ReleaseConfiguration->DefineConstants["DEBUG"] = '0'; // Debugging constant if the program wishes to check for this
$ReleaseConfiguration->name = 'release';
$ReleaseConfiguration->output_path = 'build/release';
$ReleaseConfiguration->define_constants["DEBUG"] = '0'; // Debugging constant if the program wishes to check for this
$this->project_configuration->build->build_configurations[] = $ReleaseConfiguration;
// Finally, create project.json

View file

@ -84,24 +84,24 @@
*/
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->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->getDataPath();
$this->Packages[$package->assembly->Package] = $package_entry;
$this->Packages[$package->assembly->package] = $package_entry;
$this->update();
return;
}
$this->Packages[$package->assembly->Package]->UpdateSource = $package->header->UpdateSource;
$this->Packages[$package->assembly->Package]->addVersion($package, $install_path, true);
$this->Packages[$package->assembly->Package]->getDataPath();
$this->Packages[$package->assembly->package]->UpdateSource = $package->header->UpdateSource;
$this->Packages[$package->assembly->package]->addVersion($package, $install_path, true);
$this->Packages[$package->assembly->package]->getDataPath();
$this->update();
}

View file

@ -154,14 +154,14 @@
{
try
{
if ($this->getVersion($package->assembly->Version) !== null)
if ($this->getVersion($package->assembly->version) !== null)
{
if(!$overwrite)
{
return false;
}
$this->removeVersion($package->assembly->Version);
$this->removeVersion($package->assembly->version);
}
}
catch (VersionNotFoundException $e)
@ -170,7 +170,7 @@
}
$version = new VersionEntry();
$version->Version = $package->assembly->Version;
$version->Version = $package->assembly->version;
$version->Compiler = $package->header->CompilerExtension;
$version->ExecutionUnits = $package->execution_units;
$version->MainExecutionPolicy = $package->main_execution_policy;

View file

@ -331,44 +331,44 @@
if($execution_policy?->exit_handlers !== null)
{
if(
$execution_policy?->exit_handlers->Success !== null &&
$execution_policy?->exit_handlers->Success->Run !== null
$execution_policy?->exit_handlers->success !== 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 = [];
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))
{
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;
}
}
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))
{
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;

View file

@ -1,24 +1,24 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
@ -26,6 +26,7 @@
use ncc\Enums\RegexPatterns;
use ncc\Exceptions\InvalidProjectConfigurationException;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Utilities\Functions;
use ncc\Utilities\Validate;
@ -33,68 +34,68 @@
* @author Zi Xing Narrakas
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
*/
class Assembly
class Assembly implements BytecodeObjectInterface
{
/**
* The software name
*
* @var string
*/
public $Name;
public $name;
/**
* The package name used to identify the package
*
* @var string
*/
public $Package;
public $package;
/**
* The software description
*
* @var string|null
*/
public $Description;
public $description;
/**
* @var string|null
*/
public $Company;
public $company;
/**
* The product name
*
* @var string|null
*/
public $Product;
public $product;
/**
* The copyright header for the product
*
* @var string|null
*/
public $Copyright;
public $copyright;
/**
* Product trademark
*
* @var string|null
*/
public $Trademark;
public $trademark;
/**
* Software version
*
* @var string
*/
public $Version;
public $version;
/**
* Universally Unique Identifier
*
* @var string
*/
public $UUID;
public $uuid;
/**
* Validates the object information to detect possible errors
@ -105,73 +106,92 @@
*/
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)
{
throw new InvalidProjectConfigurationException('The UUID is not a valid v4 UUID', 'Assembly.UUID');
}
return false;
}
if($this->Version !== null && !Validate::version($this->Version))
if($this->version !== null && !Validate::version($this->version))
{
if($throw_exception)
{
throw new InvalidProjectConfigurationException('The version number is invalid', 'Assembly.Version');
}
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)
{
throw new InvalidProjectConfigurationException('The package name is invalid', 'Assembly.Package');
}
return false;
}
if($this->Name !== null && strlen($this->Name) > 126)
if($this->name !== null && strlen($this->name) > 126)
{
if($throw_exception)
{
throw new InvalidProjectConfigurationException('The name cannot be larger than 126 characters', 'Assembly.Name');
}
return false;
}
if($this->Description !== null && strlen($this->Description) > 512)
if($this->description !== null && strlen($this->description) > 512)
{
if($throw_exception)
{
throw new InvalidProjectConfigurationException('The description cannot be larger than 512 characters', 'Assembly.Description');
}
return false;
}
if($this->Company !== null && strlen($this->Company) > 126)
if($this->company !== null && strlen($this->company) > 126)
{
if($throw_exception)
{
throw new InvalidProjectConfigurationException('The company cannot be larger than 126 characters', 'Assembly.Company');
}
return false;
}
if($this->Product !== null && strlen($this->Product) > 256)
if($this->product !== null && strlen($this->product) > 256)
{
if($throw_exception)
{
throw new InvalidProjectConfigurationException('The company cannot be larger than 256 characters', 'Assembly.Product');
}
return false;
}
if($this->Copyright !== null && strlen($this->Copyright) > 256)
if($this->copyright !== null && strlen($this->copyright) > 256)
{
if($throw_exception)
{
throw new InvalidProjectConfigurationException('The copyright cannot be larger than 256 characters', 'Assembly.Copyright');
}
return false;
}
if($this->Trademark !== null && strlen($this->Trademark) > 256)
if($this->trademark !== null && strlen($this->trademark) > 256)
{
if($throw_exception)
{
throw new InvalidProjectConfigurationException('The trademark cannot be larger than 256 characters', 'Assembly.Trademark');
}
return false;
}
@ -180,65 +200,77 @@
}
/**
* Returns an array representation of the object
*
* @param bool $bytecode
* @return array
* @inheritDoc
*/
public function toArray(bool $bytecode=false): array
{
$return_results = [];
$results = [];
if($this->Name !== null && strlen($this->Name) > 0)
$return_results[($bytecode ? Functions::cbc('name') : 'name')] = $this->Name;
if($this->name !== null && $this->name !== '')
{
$results[($bytecode ? Functions::cbc('name') : 'name')] = $this->name;
}
if($this->Package !== null && strlen($this->Package) > 0)
$return_results[($bytecode ? Functions::cbc('package') : 'package')] = $this->Package;
if($this->package !== null && $this->package !== '')
{
$results[($bytecode ? Functions::cbc('package') : 'package')] = $this->package;
}
if($this->Description !== null && strlen($this->Description) > 0)
$return_results[($bytecode ? Functions::cbc('description') : 'description')] = $this->Description;
if($this->description !== null && $this->description !== '')
{
$results[($bytecode ? Functions::cbc('description') : 'description')] = $this->description;
}
if($this->Company !== null && strlen($this->Company) > 0)
$return_results[($bytecode ? Functions::cbc('company') : 'company')] = $this->Company;
if($this->company !== null && $this->company !== '')
{
$results[($bytecode ? Functions::cbc('company') : 'company')] = $this->company;
}
if($this->Product !== null && strlen($this->Product) > 0)
$return_results[($bytecode ? Functions::cbc('product') : 'product')] = $this->Product;
if($this->product !== null && $this->product !== '')
{
$results[($bytecode ? Functions::cbc('product') : 'product')] = $this->product;
}
if($this->Copyright !== null && strlen($this->Copyright) > 0)
$return_results[($bytecode ? Functions::cbc('copyright') : 'copyright')] = $this->Copyright;
if($this->copyright !== null && $this->copyright !== '')
{
$results[($bytecode ? Functions::cbc('copyright') : 'copyright')] = $this->copyright;
}
if($this->Trademark !== null && strlen($this->Trademark) > 0)
$return_results[($bytecode ? Functions::cbc('trademark') : 'trademark')] = $this->Trademark;
if($this->trademark !== null && $this->trademark !== '')
{
$results[($bytecode ? Functions::cbc('trademark') : 'trademark')] = $this->trademark;
}
if($this->Version !== null && strlen($this->Version) > 0)
$return_results[($bytecode ? Functions::cbc('version') : 'version')] = $this->Version;
if($this->version !== null && $this->version !== '')
{
$results[($bytecode ? Functions::cbc('version') : 'version')] = $this->version;
}
if($this->UUID !== null && strlen($this->UUID) > 0)
$return_results[($bytecode ? Functions::cbc('uuid') : 'uuid')] = $this->UUID;
if($this->uuid !== null && $this->uuid !== '')
{
$results[($bytecode ? Functions::cbc('uuid') : 'uuid')] = $this->uuid;
}
return $return_results;
return $results;
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return Assembly
* @inheritDoc
*/
public static function fromArray(array $data): Assembly
{
$AssemblyObject = new Assembly();
$object = new self();
$AssemblyObject->Name = Functions::array_bc($data, 'name');
$AssemblyObject->Package = Functions::array_bc($data, 'package');
$AssemblyObject->Description = Functions::array_bc($data, 'description');
$AssemblyObject->Company = Functions::array_bc($data, 'company');
$AssemblyObject->Product = Functions::array_bc($data, 'product');
$AssemblyObject->Copyright = Functions::array_bc($data, 'copyright');
$AssemblyObject->Trademark = Functions::array_bc($data, 'trademark');
$AssemblyObject->Version = Functions::array_bc($data, 'version');
$AssemblyObject->UUID = Functions::array_bc($data, 'uuid');
$object->name = Functions::array_bc($data, 'name');
$object->package = Functions::array_bc($data, 'package');
$object->description = Functions::array_bc($data, 'description');
$object->company = Functions::array_bc($data, 'company');
$object->product = Functions::array_bc($data, 'product');
$object->copyright = Functions::array_bc($data, 'copyright');
$object->trademark = Functions::array_bc($data, 'trademark');
$object->version = Functions::array_bc($data, 'version');
$object->uuid = Functions::array_bc($data, 'uuid');
return $AssemblyObject;
return $object;
}
}

View file

@ -192,11 +192,11 @@
$build_configurations = [];
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)
{
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;
@ -214,7 +214,7 @@
}
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)
{
$build_configurations[] = $configuration->Name;
$build_configurations[] = $configuration->name;
}
return $build_configurations;
@ -278,7 +278,7 @@
foreach($this->build_configurations as $configuration)
{
if($configuration->Name === $name)
if($configuration->name === $name)
{
return $configuration;
}

View file

@ -1,24 +1,24 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
@ -26,6 +26,7 @@
use ncc\Exceptions\InvalidBuildConfigurationException;
use ncc\Exceptions\InvalidDependencyConfiguration;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Objects\ProjectConfiguration\Dependency;
use ncc\Utilities\Functions;
use ncc\Utilities\Validate;
@ -34,56 +35,56 @@
* @author Zi Xing Narrakas
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
*/
class BuildConfiguration
class BuildConfiguration implements BytecodeObjectInterface
{
/**
* The unique name of the build configuration
*
* @var string
*/
public $Name;
public $name;
/**
* Options to pass onto the extension compiler
*
* @var array
*/
public $Options;
public $options;
/**
* The build output path for the build configuration, eg; build/%BUILD.NAME%
*
* @var string
*/
public $OutputPath;
public $output_path;
/**
* An array of constants to define for the build when importing or executing.
*
* @var string[]
*/
public $DefineConstants;
public $define_constants;
/**
* An array of files to exclude in this build configuration
*
* @var string[]
*/
public $ExcludeFiles;
public $exclude_files;
/**
* An array of policies to execute pre-building the package
*
* @var string[]|string
*/
public $PreBuild;
public $pre_build;
/**
* An array of policies to execute post-building the package
*
* @var string
*/
public $PostBuild;
public $post_build;
/**
* Dependencies required for the build configuration, cannot conflict with the
@ -91,20 +92,20 @@
*
* @var Dependency[]
*/
public $Dependencies;
public $dependencies;
/**
* Public Constructor
*/
public function __construct()
{
$this->Options = [];
$this->OutputPath = 'build';
$this->DefineConstants = [];
$this->ExcludeFiles = [];
$this->PreBuild = [];
$this->PostBuild = [];
$this->Dependencies = [];
$this->options = [];
$this->output_path = 'build';
$this->define_constants = [];
$this->exclude_files = [];
$this->pre_build = [];
$this->post_build = [];
$this->dependencies = [];
}
/**
@ -116,74 +117,92 @@
*/
public function validate(bool $throw_exception=True): bool
{
if(!Validate::nameFriendly($this->Name))
if(!Validate::nameFriendly($this->name))
{
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;
}
if(!Validate::pathName($this->OutputPath))
if(!Validate::pathName($this->output_path))
{
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;
}
if($this->DefineConstants !== null && !is_array($this->DefineConstants))
if($this->define_constants !== null && !is_array($this->define_constants))
{
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;
}
if($this->ExcludeFiles !== null && !is_array($this->ExcludeFiles))
if($this->exclude_files !== null && !is_array($this->exclude_files))
{
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;
}
if($this->PreBuild !== null && !is_array($this->PreBuild))
if($this->pre_build !== null && !is_array($this->pre_build))
{
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;
}
if($this->PostBuild !== null && !is_array($this->PostBuild))
if($this->post_build !== null && !is_array($this->post_build))
{
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;
}
if($this->Dependencies !== null && !is_array($this->Dependencies))
if($this->dependencies !== null && !is_array($this->dependencies))
{
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;
}
/** @var Dependency $dependency */
foreach($this->Dependencies as $dependency)
foreach($this->dependencies as $dependency)
{
try
{
if (!$dependency->validate($throw_exception))
{
return False;
}
}
catch (InvalidDependencyConfiguration $e)
{
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;
}
@ -193,64 +212,78 @@
}
/**
* Returns an array representation of the object
*
* @param boolean $bytecode
* @return array
* @inheritDoc
*/
public function toArray(bool $bytecode=false): array
{
$ReturnResults = [];
$results = [];
if($this->Name !== null && strlen($this->Name) > 0)
$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)
if($this->name !== null && $this->name !== '')
{
$Dependencies = [];
foreach($this->Dependencies as $Dependency)
{
$Dependencies[] = $Dependency->toArray($bytecode);
}
$ReturnResults[($bytecode ? Functions::cbc('dependencies') : 'dependencies')] = $Dependencies;
$results[($bytecode ? Functions::cbc('name') : 'name')] = $this->name;
}
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
*
* @param array $data
* @return BuildConfiguration
* @inheritDoc
*/
public static function fromArray(array $data): BuildConfiguration
{
$BuildConfigurationObject = new BuildConfiguration();
$object = new BuildConfiguration();
$BuildConfigurationObject->Name = Functions::array_bc($data, 'name');
$BuildConfigurationObject->Options = Functions::array_bc($data, 'options');
$BuildConfigurationObject->OutputPath = Functions::array_bc($data, 'output_path');
$BuildConfigurationObject->DefineConstants = Functions::array_bc($data, 'define_constants');
$BuildConfigurationObject->ExcludeFiles = Functions::array_bc($data, 'exclude_files');
$BuildConfigurationObject->PreBuild = Functions::array_bc($data, 'pre_build');
$BuildConfigurationObject->PostBuild = Functions::array_bc($data, 'post_build');
$object->name = Functions::array_bc($data, 'name');
$object->options = Functions::array_bc($data, 'options');
$object->output_path = Functions::array_bc($data, 'output_path');
$object->define_constants = Functions::array_bc($data, 'define_constants');
$object->exclude_files = Functions::array_bc($data, 'exclude_files');
$object->pre_build = Functions::array_bc($data, 'pre_build');
$object->post_build = Functions::array_bc($data, 'post_build');
if(Functions::array_bc($data, 'dependencies') !== null)
{
foreach(Functions::array_bc($data, 'dependencies') as $item)
$BuildConfigurationObject->Dependencies[] = Dependency::fromArray($item);
{
$object->dependencies[] = Dependency::fromArray($item);
}
}
return $BuildConfigurationObject;
return $object;
}
}

View file

@ -1,39 +1,40 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Utilities\Functions;
class Execute
class Execute implements BytecodeObjectInterface
{
/**
* The target file to execute
*
* @var string
*/
public $Target;
public $target;
/**
* The working directory to execute the policy in, if not specified the
@ -41,35 +42,35 @@
*
* @var string|null
*/
public $WorkingDirectory;
public $working_directory;
/**
* Options to pass to the process
*
* @var array
*/
public $Options;
public $options;
/**
* An array of environment variables to pass on to the process
*
* @var array|null
*/
public $EnvironmentVariables;
public $environment_variables;
/**
* Indicates if the output should be displayed or suppressed
*
* @var bool|null
*/
public $Silent;
public $silent;
/**
* Indicates if the process should run in Tty mode (Overrides Silent & Pty mode)
*
* @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
@ -77,80 +78,90 @@
*
* @var int|null
*/
public $Timeout;
public $timeout;
/**
* @var int|null
*/
public $IdleTimeout;
public $idle_timeout;
/**
* Public Constructor
*/
public function __construct()
{
$this->Tty = false;
$this->Silent = false;
$this->Timeout = null;
$this->IdleTimeout = null;
$this->WorkingDirectory = "%CWD%";
$this->tty = false;
$this->silent = false;
$this->timeout = null;
$this->idle_timeout = null;
$this->working_directory = "%CWD%";
}
/**
* Returns an array representation of the object
*
* @param bool $bytecode
* @return array
* @inheritDoc
*/
public function toArray(bool $bytecode=false): array
{
$results = [];
if($this->Target !== null)
$results[($bytecode ? Functions::cbc("target") : "target")] = $this->Target;
if($this->target !== null)
{
$results[($bytecode ? Functions::cbc('target') : 'target')] = $this->target;
}
if($this->WorkingDirectory !== null)
$results[($bytecode ? Functions::cbc("working_directory") : "working_directory")] = $this->WorkingDirectory;
if($this->working_directory !== null)
{
$results[($bytecode ? Functions::cbc('working_directory') : 'working_directory')] = $this->working_directory;
}
if($this->Options !== null)
$results[($bytecode ? Functions::cbc("options") : "options")] = $this->Options;
if($this->options !== null)
{
$results[($bytecode ? Functions::cbc('options') : 'options')] = $this->options;
}
if($this->EnvironmentVariables !== null)
$results[($bytecode ? Functions::cbc("environment_variables") : "environment_variables")] = $this->EnvironmentVariables;
if($this->environment_variables !== null)
{
$results[($bytecode ? Functions::cbc('environment_variables') : 'environment_variables')] = $this->environment_variables;
}
if($this->Silent !== null)
$results[($bytecode ? Functions::cbc("silent") : "silent")] = (bool)$this->Silent;
if($this->silent !== null)
{
$results[($bytecode ? Functions::cbc('silent') : 'silent')] = (bool)$this->silent;
}
if($this->Tty !== null)
$results[($bytecode ? Functions::cbc("tty") : "tty")] = (bool)$this->Tty;
if($this->tty !== null)
{
$results[($bytecode ? Functions::cbc('tty') : 'tty')] = (bool)$this->tty;
}
if($this->Timeout !== null)
$results[($bytecode ? Functions::cbc("timeout") : "timeout")] = (int)$this->Timeout;
if($this->timeout !== null)
{
$results[($bytecode ? Functions::cbc('timeout') : 'timeout')] = (int)$this->timeout;
}
if($this->IdleTimeout !== null)
$results[($bytecode ? Functions::cbc("idle_timeout") : "idle_timeout")] = (int)$this->IdleTimeout;
if($this->idle_timeout !== null)
{
$results[($bytecode ? Functions::cbc('idle_timeout') : 'idle_timeout')] = (int)$this->idle_timeout;
}
return $results;
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return Execute
* @inheritDoc
*/
public static function fromArray(array $data): self
public static function fromArray(array $data): Execute
{
$object = new self();
$object->Target = Functions::array_bc($data, 'target');
$object->WorkingDirectory = Functions::array_bc($data, 'working_directory');
$object->Options = Functions::array_bc($data, 'options');
$object->EnvironmentVariables = Functions::array_bc($data, 'environment_variables');
$object->Silent = Functions::array_bc($data, 'silent');
$object->Tty = Functions::array_bc($data, 'tty');
$object->Timeout = Functions::array_bc($data, 'timeout');
$object->IdleTimeout = Functions::array_bc($data, 'idle_timeout');
$object->target = Functions::array_bc($data, 'target');
$object->working_directory = Functions::array_bc($data, 'working_directory');
$object->options = Functions::array_bc($data, 'options');
$object->environment_variables = Functions::array_bc($data, 'environment_variables');
$object->silent = Functions::array_bc($data, 'silent');
$object->tty = Functions::array_bc($data, 'tty');
$object->timeout = Functions::array_bc($data, 'timeout');
$object->idle_timeout = Functions::array_bc($data, 'idle_timeout');
return $object;
}

View file

@ -1,39 +1,40 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Utilities\Functions;
class ExitHandle
class ExitHandle implements BytecodeObjectInterface
{
/**
* The message to display when the handle is triggered
*
* @var string|null
*/
public $Message;
public $message;
/**
* Indicates if the process should exit if the handle is triggered,
@ -44,61 +45,61 @@
*
* @var bool|null
*/
public $EndProcess;
public $end_process;
/**
* The name of another execution policy to execute (optionally) when this exit handle is triggered
*
* @var string|null
*/
public $Run;
public $run;
/**
* The exit code that needs to be returned from the process to trigger this handle
*
* @var int
*/
public $ExitCode;
public $exit_code;
/**
* Returns an array representation of the object
*
* @param bool $bytecode
* @return array
* @inheritDoc
*/
public function toArray(bool $bytecode=false): array
{
$return_results = [];
$results = [];
if($this->Message !== null)
$return_results[($bytecode ? Functions::cbc('message') : 'message')] = $this->Message;
if($this->message !== null)
{
$results[($bytecode ? Functions::cbc('message') : 'message')] = $this->message;
}
if($this->EndProcess !== null)
$return_results[($bytecode ? Functions::cbc('end_process') : 'end_process')] = $this->EndProcess;
if($this->end_process !== null)
{
$results[($bytecode ? Functions::cbc('end_process') : 'end_process')] = $this->end_process;
}
if($this->Run !== null)
$return_results[($bytecode ? Functions::cbc('run') : 'run')] = $this->Run;
if($this->run !== null)
{
$results[($bytecode ? Functions::cbc('run') : 'run')] = $this->run;
}
/** @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
*
* @param array $data
* @return ExitHandle
* @inheritDoc
*/
public static function fromArray(array $data): self
public static function fromArray(array $data): ExitHandle
{
$object = new self();
$object->Message = Functions::array_bc($data, 'message');
$object->EndProcess = Functions::array_bc($data, 'end_process');
$object->Run = Functions::array_bc($data, 'run');
$object->ExitCode = Functions::array_bc($data, 'exit_code');
$object->message = Functions::array_bc($data, 'message');
$object->end_process = Functions::array_bc($data, 'end_process');
$object->run = Functions::array_bc($data, 'run');
$object->exit_code = Functions::array_bc($data, 'exit_code');
return $object;
}

View file

@ -1,90 +1,91 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
namespace ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Utilities\Functions;
class ExitHandlers
class ExitHandlers implements BytecodeObjectInterface
{
/**
* 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
*
* @var ExitHandle
* @var ExitHandle|null
*/
public $Warning;
public $warning;
/**
* 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
*
* @param bool $bytecode
* @return array
* @inheritDoc
*/
public function toArray(bool $bytecode=false): array
{
return [
($bytecode ? Functions::cbc('success') : 'success') => $this->Success?->toArray($bytecode),
($bytecode ? Functions::cbc('warning') : 'warning') => $this->Warning?->toArray($bytecode),
($bytecode ? Functions::cbc('error') : 'error') => $this->Error?->toArray($bytecode),
($bytecode ? Functions::cbc('success') : 'success') => $this->success?->toArray($bytecode),
($bytecode ? Functions::cbc('warning') : 'warning') => $this->warning?->toArray($bytecode),
($bytecode ? Functions::cbc('error') : 'error') => $this->error?->toArray($bytecode),
];
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return ExitHandlers
* @inheritDoc
*/
public static function fromArray(array $data): self
{
$object = new self();
$object->Success = Functions::array_bc($data, 'success');
if($object->Success !== null)
$object->Success = ExitHandle::fromArray($object->Success);
$object->success = Functions::array_bc($data, 'success');
if($object->success !== null)
{
$object->success = ExitHandle::fromArray($object->success);
}
$object->Warning = Functions::array_bc($data, 'warning');
if($object->Warning !== null)
$object->Warning = ExitHandle::fromArray($object->Warning);
$object->warning = Functions::array_bc($data, 'warning');
if($object->warning !== null)
{
$object->warning = ExitHandle::fromArray($object->warning);
}
$object->Error = Functions::array_bc($data, 'error');
if($object->Error !== null)
$object->Error = ExitHandle::fromArray($object->Error);
$object->error = Functions::array_bc($data, 'error');
if($object->error !== null)
{
$object->error = ExitHandle::fromArray($object->error);
}
return $object;
}

View file

@ -1,90 +1,87 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
namespace ncc\Objects\ProjectConfiguration\UpdateSource;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Utilities\Functions;
class Repository
class Repository implements BytecodeObjectInterface
{
/**
* The name of the remote source to add
*
* @var string
*/
public $Name;
public $name;
/**
* The type of client that is used to connect to the remote source
*
* @var string|null
*/
public $Type;
public $type;
/**
* The host of the remote source
*
* @var string
*/
public $Host;
public $host;
/**
* If SSL should be used
*
* @var bool
*/
public $SSL;
public $ssl;
/**
* Returns an array representation of the object
*
* @param bool $bytecode
* @return array
* @inheritDoc
*/
public function toArray(bool $bytecode=false): array
{
return [
($bytecode ? Functions::cbc('name') : 'name') => $this->Name,
($bytecode ? Functions::cbc('type') : 'type') => $this->Type,
($bytecode ? Functions::cbc('host') : 'host') => $this->Host,
($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->SSL
($bytecode ? Functions::cbc('name') : 'name') => $this->name,
($bytecode ? Functions::cbc('type') : 'type') => $this->type,
($bytecode ? Functions::cbc('host') : 'host') => $this->host,
($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->ssl
];
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return Repository
* @inheritDoc
*/
public static function fromArray(array $data): self
public static function fromArray(array $data): Repository
{
$obj = new self();
$obj->Name = Functions::array_bc($data, 'name');
$obj->Type = Functions::array_bc($data, 'type');
$obj->Host = Functions::array_bc($data, 'host');
$obj->SSL = Functions::array_bc($data, 'ssl');
return $obj;
$object = new self();
$object->name = Functions::array_bc($data, 'name');
$object->type = Functions::array_bc($data, 'type');
$object->host = Functions::array_bc($data, 'host');
$object->ssl = Functions::array_bc($data, 'ssl');
return $object;
}
}