def __get_package(self, name: str) -> Optional[HBShedPackageHandler]: target_path: Path = self.__node_modules.joinpath(name) if not target_path.is_dir(): raise FileNotFoundError('Package : ' + name + ' not found at : ' + self.__node_modules.as_posix()) return HBShedPackageHandler.from_package_handler( PackageHandler(target_path))
def process(self, package: PackageHandler): hb_package: Optional[ HBShedPackageHandler] = HBShedPackageHandler.from_package_handler( package) if hb_package is not None: if hb_package.config().has_parent_external(): if self.parents.get(hb_package.config().parent_name()): if hb_package.config().has_parent_version( ) and self.parents.get(hb_package.config().parent_name( )) is not None and self.parents.get(hb_package.config( ).parent_name()) != hb_package.config().parent_version(): raise ImportError( 'Version conflict with parent package : ' + package.name() + ' parent: ' + hb_package.config().parent_name() + ' version:' + hb_package.config().parent_version() + ' because version : ' + self.parents.get( hb_package.config().parent_name()) + ' already registered') self.parents[hb_package.config().parent_name( )] = hb_package.config().parent_version()
def ensure_current_package(self) -> PackageHandler: target_path: Path = self.node_modules.joinpath(self.target_package_name) if not target_path.is_dir(): raise FileNotFoundError( 'Package : ' + self.target_package_name + ' not found at : ' + self.node_modules.as_posix()) package: PackageHandler = PackageHandler(target_path) if re.match(re.compile('.*\.git$'), self.target_package_version) is None: if package.version() != self.target_package_version: raise ImportError( 'Package : ' + self.prev_package.name() + ' version conflict with package : ' + self.target_package_name + ':' + self.target_package_version + ' version : ' + package.version() + ' already registered') return package
def __ensure_load_package(self): self.__package = PackageHandler(self.__cwd)
def __ensure_load_hb_package(self): self.__package = HBShedPackageHandler(self.__cwd) self.__package.config()
class TaskBuilder: __package: Optional[PackageHandler] = None def __init__(self, tasks: List[Tasks], options: Options, cwd: Path) -> None: self.__cwd: Path = cwd self.__tasks: List[Tasks] = tasks self.__options: Options = options def __ensure_load_hb_package(self): self.__package = HBShedPackageHandler(self.__cwd) self.__package.config() def __ensure_load_package(self): self.__package = PackageHandler(self.__cwd) def process(self): task: Tasks for task in self.__tasks: if task == Tasks.TEST: self.__ensure_load_hb_package() Test(self.__options, self.__package, self.__cwd).process() elif task == Tasks.SELF_INSTALL: p: Path = Path( os.path.dirname(os.path.realpath(__file__)) + '/../../..') p.resolve() SelfInstall(self.__options, HBShedPackageHandler(p), p).process() elif task == Tasks.INSTALL: self.__ensure_load_hb_package() Install(self.__options, self.__package, self.__cwd).process() elif task == Tasks.CLEAN: self.__ensure_load_hb_package() Clean(self.__options, self.__package, self.__cwd).process() elif task == Tasks.CLEAN_DEPENDENCIES_DIR: self.__ensure_load_hb_package() CleanDependenciesDir(self.__options, self.__package, self.__cwd).process() elif task == Tasks.CLEAN_SOURCES: self.__ensure_load_hb_package() CleanSources(self.__options, self.__package, self.__cwd).process() elif task == Tasks.CLEAN_BUILD: self.__ensure_load_hb_package() CleanBuild(self.__options, self.__package, self.__cwd).process() elif task == Tasks.DEV: self.__ensure_load_hb_package() Dev(self.__options, self.__package, self.__cwd).process() elif task == Tasks.BROWSER_TEST: self.__ensure_load_hb_package() BrowserTest(self.__options, self.__package, self.__cwd).process() elif task == Tasks.EXTRACT_PACKAGE: self.__ensure_load_hb_package() ExtractPackage(self.__options, self.__package, self.__cwd).process() elif task == Tasks.BUILD: self.__ensure_load_hb_package() Build(self.__options, self.__package, self.__cwd).process() elif task == Tasks.GENERATE_SOURCES: self.__ensure_load_hb_package() GenerateSources(self.__options, self.__package, self.__cwd).process() elif task == Tasks.SET_FLEXIO_REGISTRY: SetFlexioRegistry(self.__options, self.__package, self.__cwd).process() elif task == Tasks.PUBLISH: self.__ensure_load_package() Publish(self.__options, self.__package, self.__cwd).process() else: raise ValueError('no tasks for this command')
def __get_package(self, name: str) -> PackageHandler: target_path: Path = self.__node_modules.joinpath(name) if not target_path.is_dir(): raise FileNotFoundError('Package : ' + name + ' not found at : ' + self.__node_modules.as_posix()) return PackageHandler(target_path)