Added Data path for packages
This commit is contained in:
parent
558c0a3212
commit
7ffbdf72c1
5 changed files with 87 additions and 1 deletions
|
@ -4,7 +4,11 @@
|
||||||
use ncc\Exceptions\ConstantReadonlyException;
|
use ncc\Exceptions\ConstantReadonlyException;
|
||||||
use ncc\Exceptions\ImportException;
|
use ncc\Exceptions\ImportException;
|
||||||
use ncc\Exceptions\InvalidConstantNameException;
|
use ncc\Exceptions\InvalidConstantNameException;
|
||||||
use ncc\ncc;
|
use ncc\Exceptions\InvalidPackageNameException;
|
||||||
|
use ncc\Exceptions\InvalidScopeException;
|
||||||
|
use ncc\Exceptions\PackageLockException;
|
||||||
|
use ncc\Exceptions\PackageNotFoundException;
|
||||||
|
use ncc\ncc;
|
||||||
use ncc\Runtime;
|
use ncc\Runtime;
|
||||||
|
|
||||||
if(!defined('NCC_INIT'))
|
if(!defined('NCC_INIT'))
|
||||||
|
@ -112,4 +116,22 @@
|
||||||
Runtime\Constants::delete($package, $name);
|
Runtime\Constants::delete($package, $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!function_exists('get_data_path'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the data path of the package
|
||||||
|
*
|
||||||
|
* @param string $package
|
||||||
|
* @return string
|
||||||
|
* @throws InvalidPackageNameException
|
||||||
|
* @throws InvalidScopeException
|
||||||
|
* @throws PackageLockException
|
||||||
|
* @throws PackageNotFoundException
|
||||||
|
*/
|
||||||
|
function get_data_path(string $package): string
|
||||||
|
{
|
||||||
|
return Runtime::getDataPath($package);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -65,6 +65,7 @@
|
||||||
$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();
|
||||||
$this->Packages[$package->Assembly->Package] = $package_entry;
|
$this->Packages[$package->Assembly->Package] = $package_entry;
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@
|
||||||
|
|
||||||
$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, true);
|
$this->Packages[$package->Assembly->Package]->addVersion($package, true);
|
||||||
|
$this->Packages[$package->Assembly->Package]->getDataPath();
|
||||||
$this->update();
|
$this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,17 @@
|
||||||
|
|
||||||
namespace ncc\Objects\PackageLock;
|
namespace ncc\Objects\PackageLock;
|
||||||
|
|
||||||
|
use ncc\Abstracts\Scopes;
|
||||||
|
use ncc\Exceptions\InvalidPackageNameException;
|
||||||
|
use ncc\Exceptions\InvalidScopeException;
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\VersionNotFoundException;
|
||||||
use ncc\Objects\Package;
|
use ncc\Objects\Package;
|
||||||
use ncc\Objects\ProjectConfiguration\UpdateSource;
|
use ncc\Objects\ProjectConfiguration\UpdateSource;
|
||||||
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
||||||
|
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
use ncc\Utilities\PathFinder;
|
||||||
|
use ncc\Utilities\Resolver;
|
||||||
|
|
||||||
class PackageEntry
|
class PackageEntry
|
||||||
{
|
{
|
||||||
|
@ -194,6 +200,24 @@
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @throws InvalidPackageNameException
|
||||||
|
* @throws InvalidScopeException
|
||||||
|
*/
|
||||||
|
public function getDataPath(): string
|
||||||
|
{
|
||||||
|
$path = PathFinder::getPackageDataPath($this->Name);
|
||||||
|
|
||||||
|
if(!file_exists($path) && Resolver::resolveScope() == Scopes::System)
|
||||||
|
{
|
||||||
|
$filesystem = new Filesystem();
|
||||||
|
$filesystem->mkdir($path, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* Returns an array representation of the object
|
||||||
*
|
*
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
use ncc\Classes\PhpExtension\PhpRuntime;
|
use ncc\Classes\PhpExtension\PhpRuntime;
|
||||||
use ncc\Exceptions\ImportException;
|
use ncc\Exceptions\ImportException;
|
||||||
use ncc\Exceptions\PackageLockException;
|
use ncc\Exceptions\PackageLockException;
|
||||||
|
use ncc\Exceptions\PackageNotFoundException;
|
||||||
use ncc\Exceptions\VersionNotFoundException;
|
use ncc\Exceptions\VersionNotFoundException;
|
||||||
use ncc\Managers\PackageManager;
|
use ncc\Managers\PackageManager;
|
||||||
use ncc\Objects\PackageLock\VersionEntry;
|
use ncc\Objects\PackageLock\VersionEntry;
|
||||||
|
@ -137,6 +138,26 @@
|
||||||
self::addImport($package, $version);
|
self::addImport($package, $version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the data path of the package
|
||||||
|
*
|
||||||
|
* @param string $package
|
||||||
|
* @return string
|
||||||
|
* @throws Exceptions\InvalidPackageNameException
|
||||||
|
* @throws Exceptions\InvalidScopeException
|
||||||
|
* @throws PackageLockException
|
||||||
|
* @throws PackageNotFoundException
|
||||||
|
*/
|
||||||
|
public static function getDataPath(string $package): string
|
||||||
|
{
|
||||||
|
$package = self::getPackageManager()->getPackage($package);
|
||||||
|
|
||||||
|
if($package == null)
|
||||||
|
throw new PackageNotFoundException(sprintf('Package %s not found', $package));
|
||||||
|
|
||||||
|
return $package->getDataPath();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PackageManager
|
* @return PackageManager
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use ncc\Abstracts\Runners;
|
use ncc\Abstracts\Runners;
|
||||||
use ncc\Abstracts\Scopes;
|
use ncc\Abstracts\Scopes;
|
||||||
|
use ncc\Exceptions\InvalidPackageNameException;
|
||||||
use ncc\Exceptions\InvalidScopeException;
|
use ncc\Exceptions\InvalidScopeException;
|
||||||
use ncc\Exceptions\RunnerExecutionException;
|
use ncc\Exceptions\RunnerExecutionException;
|
||||||
use ncc\ThirdParty\Symfony\Process\ExecutableFinder;
|
use ncc\ThirdParty\Symfony\Process\ExecutableFinder;
|
||||||
|
@ -204,6 +205,22 @@
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path where package data is located
|
||||||
|
*
|
||||||
|
* @param string $package
|
||||||
|
* @return string
|
||||||
|
* @throws InvalidPackageNameException
|
||||||
|
* @throws InvalidScopeException
|
||||||
|
*/
|
||||||
|
public static function getPackageDataPath(string $package): string
|
||||||
|
{
|
||||||
|
if(!Validate::packageName($package))
|
||||||
|
throw new InvalidPackageNameException($package);
|
||||||
|
|
||||||
|
return self::getDataPath() . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . $package;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file path where files for the given extension is stored
|
* Returns the file path where files for the given extension is stored
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue