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:----I7gCtpjVDfV88mTbZVUGY+ygaSwDd1XXzl2XDoTmxzrJ9b32TXJAxfZAMdXN6PqHaHY1joFTKO7P3L54K7CnaFNOzJzEaHUfpfWNTsnZTQTQ4/+jvhvr6ltn51SdqlKdS///w5CafGjwKWk+2CvCrHXadnq0z8dOQHgbR3FhYuPrEqRWutdnWN4rPZ2DgFHw/ZBqZDSGrniq4SFxriuk0BaLKOPOCdEe4xBQy3OkCZMDRhy4hPjtbp6iWKi98WTj7qXmjeHB5tvCB9lMzZ7qKe2cjiADlYI87cc3EgkfpMXmq9eRBy2MjFOEvrxOtUWImP+kp/ZPhninXxmQGrPQiiDmmWWKKPCjSGyoNz+CprXNLhtMLGQWVa66lBKNuVIK78Acqkwa9wSVwafH0VgVl+XJOae68rUsACRGZjf8hy3EZUDUReZbRWI7yRhTmbdz8kPpneWd6QcTZGP23ewA+E8W7HmJju8TFfhdoNOZbgov/kcCUNY0OO0vtGwkpYEl04de/02zZjJBgxeYfqRTOExyO1hq5YwB0zFHf5Tx1Uqha59NOagU+rb+XAHhg6pWGll9D9i21tI4zjxN6XvPqDVI6hivnolv4o/TqLzhWQpPZWu942eyfaDAQ9ynWlxdIzFuuCKq3fxsbvjvR3ZQPVvDwu4rgneCF+nEqdr6SNk=----ATTACHMENT:----NjIyOTk4OTY1ODc5Mjc4MiA2MjQ4Njc3OTY4MDM0ODk5IDk4NTY0MDkxMDgyMjE4MTk=