AuthShield = $AuthShield; $this->container=(null!==$container) ? $container : $AuthShield->getAppShield()->getContainer(); } /** public function auth(\UMA\JsonRpc\Request $request){ return 'admin' === $this->container->get('webfan.app.fsm.user')->getCurrentState()->getName(); } * {@inheritdoc} const CONFIG_FILENAME = 'frdl.stub.config.php'; const WORKSPACES_FILENAME = 'frdl.workspaces.php'; const VERSION_FILENAME = 'frdl.version.config.php'; const BASH_FILENAME = '.bashrc_profile'; //const BASH_FILENAME = '.bashrc-frdl'; const PROJECT_FILENAME = 'frdl.project.json'; const DEPLOYMENT_FILENAME = 'frdl.deployment.json'; const STAGES_FILENAME = 'frdl.stages.json'; const CONFIG_PROJECT_FILENAME = 'frdl.project.config.php'; */ protected function loadProjectFiles($dir, $project){ $dir = rtrim($dir, \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR; $CONFIG_PROJECT_FILENAME = $dir . Shield::CONFIG_FILENAME; if(file_exists($CONFIG_PROJECT_FILENAME)){ $project['config']['project'] = require $CONFIG_PROJECT_FILENAME; } foreach([ [ 'key' => 'deployment', 'file' => $dir. \DIRECTORY_SEPARATOR . Shield::DEPLOYMENT_FILENAME, ], [ 'key' => 'stages', 'file' => $dir. \DIRECTORY_SEPARATOR . Shield::STAGES_FILENAME, ], [ 'key' => 'frdl', 'file' => $dir. \DIRECTORY_SEPARATOR . Shield::PROJECT_FILENAME, ], [ 'key' => 'composer', 'file' => $dir. \DIRECTORY_SEPARATOR . 'composer.json', ], [ 'key' => 'composerLock', 'file' => $dir. \DIRECTORY_SEPARATOR .'composer.lock', ], ] as $f){ if(file_exists($f['file'])){ $project['config'][$f['key']] = json_decode(file_get_contents($f['file'])); } } return $project; } public function __invoke(\UMA\JsonRpc\Request $request): \UMA\JsonRpc\Response { $params = $request->params(); $config = $this->AuthShield->getAppShield()->config->export(); $project = false; $projectFile = $config['wsdir'] . 'frdl-projects' . \DIRECTORY_SEPARATOR . preg_replace("/^[A-Za-z0-9\-\_]/", '', $params->dir ) . \DIRECTORY_SEPARATOR . 'frdl.project.json'; if(file_exists($projectFile)){ $project = [ // '__DIR__' => \webfan\hps\patch\Fs::getRelativePath($config['wsdir'] . 'frdl-projects', dirname($projectFile)), '__DIR__' => preg_replace("/^[A-Za-z0-9\-\_]/", '', $params->dir ), 'config' => [ ], ]; /* $composerFile = dirname($projectFile) . \DIRECTORY_SEPARATOR . 'composer.json'; $lockFile = dirname($projectFile). \DIRECTORY_SEPARATOR . 'composer.lock'; $project['config']['frdl'] = json_decode(file_get_contents($projectFile)); if(file_exists($composerFile)){ $project['config']['composer'] = json_decode(file_get_contents($composerFile)); } $project['config']['composerLock'] =(file_exists($lockFile)) ? filemtime($lockFile) : 0; */ $project = $this->loadProjectFiles(dirname($projectFile), $project); } if(false === $project){ $finder = $this->container->get('finder'); $finder->name('frdl.project.json'); foreach ($finder->in([$config['wsdir'], \webfan\hps\patch\Fs::getRelativePath(getcwd(), \webfan\hps\patch\Fs::getRootDir($_SERVER['DOCUMENT_ROOT']))] ) as $file) { // $absoluteFilePath = $file->getRealPath(); // $fileNameWithExtension = $file->getRelativePathname(); if($params->dir !== dirname($file->getRealPath()) && realpath($params->dir) !== dirname($file->getRealPath()) && $params->dir !== basename(dirname($file->getRealPath())) ){ continue; } $project = [ '__DIR__' => \webfan\hps\patch\Fs::getRelativePath($config['wsdir'] . 'frdl-projects', dirname($file->getRealPath())), 'config' => [ ], ]; if(!isset($_SESSION[TerminalEmulator::SESSIONKEY])){ $_SESSION[TerminalEmulator::SESSIONKEY]=[]; } $_SESSION[TerminalEmulator::SESSIONKEY]['cwd'] = realpath(dirname($file->getRealPath())); /* $composerFile = dirname($file->getRealPath()) . \DIRECTORY_SEPARATOR . 'composer.json'; $lockFile = dirname($file->getRealPath()) . \DIRECTORY_SEPARATOR . 'composer.lock'; $project['config']['frdl'] = json_decode($file->getContents()); if(file_exists($composerFile)){ $project['config']['composer'] = json_decode(file_get_contents($composerFile)); } $project['config']['composerLock'] =(file_exists($lockFile)) ? filemtime($lockFile) : 0; */ $project = $this->loadProjectFiles(dirname($file->getRealPath()), $project); break; } } if(false === $project){ return new \UMA\JsonRpc\Error($request->id(), sprintf('Project `%s` not found', $params->dir)); } //try{ // return new \UMA\JsonRpc\Success($request->id(), $config); //}catch(\Exception $e){ // return new \UMA\JsonRpc\Error($request->id(), 'Could get config'); //} return new \UMA\JsonRpc\Success($request->id(), $project); } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "dir" : { type : ["string"] } }, "required" : ["dir"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----TkZnMAyVuee5GXq5cinhNIBc2QRYx03xaHwSvJJma6wyyIjoPmvnhu7PgLg1bDr8S9d5v9w8NZdXGG8bwlzGuEaKFP0nTnF/c9hiOvuBNZRViK2zL2YCxt+zD1mAt2drboVOGETF/ZyLROpIxp3y7t2cIRprbPMi3rR4Ncst0immW1ptn178Z6Evczs9n8yVf4JaI3V7UZNPsnvYW4cl4iyQuT968uJmumryA/v6J9VOcBdzePnEEpPDYFZ/vMGsiVMiOSvsgEVqgd2r+hPW2gColzNLyCEwTlY67hFROZuve/by/m2Ldsnlf+SqAhrAeKZO3c5T8WNXiC4EXEFlWfD3L2xUuPZrz9YM3r51eRQDIs7czy5tQdqpOlq57l4OprWZvsVzriDrCDU/FYJfLtE4WAbjPNuyoVXzVZqKAmrgUROEvpZcnPQ663GxgI8NXBkH7WGSFSLA4sBFKK3MHywlyBndWwcD9hfOC6TZf2AcCwPgpKD7yyue7vM0lJIv+ReMaNl6eL0ESYlqG0gc8POS/ES2M6PVFWFtQSQOB7v9m+FtQ+OsLnHb/P8V2veeq4CeoGifHmDea5LXz9fycVOCJxsTCueiFZriZwX2hPkeoU5tMmnYXPEQZOeDNrNCQVPaTn7KquTstC9sEmIHyKHMmQdB785PAs6Fl0zyeqw=----ATTACHMENT:----NTgzOTg5NTIzMzE1NzgwMiA3Njg4NjM5NzQwODYzMDYyIDMxNzA1NzU0NjI2NTc4NzE=