* */ $iTopFolder = __DIR__ . "/../../" ; require_once ("$iTopFolder/approot.inc.php"); require_once (APPROOT."/setup/setuputils.class.inc.php"); if (php_sapi_name() !== 'cli') { throw new \Exception('This script can only run from CLI'); } clearstatcache(); // Read params $key = array_search("--manager", $argv); if (false === $key || false === isset($argv[$key + 1]) ) { throw new \InvalidArgumentException("Usage: " . __FILE__ . " --manager composer|npm"); } $sDependenciesHandlerCode = $argv[$key + 1]; switch ($sDependenciesHandlerCode) { case "composer": $sDependenciesHandlerFQCN = \Combodo\iTop\Dependencies\Composer\iTopComposer::class; break; case "npm": $sDependenciesHandlerFQCN = \Combodo\iTop\Dependencies\NPM\iTopNPM::class; break; default: throw new \Exception("Invalid dependencies handler code, $sDependenciesHandlerCode given, expected composer|npm"); } // Start handler $oDependenciesHandler = new $sDependenciesHandlerFQCN(); $aDeniedButStillPresent = $oDependenciesHandler->ListDeniedButStillPresentFilesAbsPaths(); echo "\n"; foreach ($aDeniedButStillPresent as $sDir) { if (false === $oDependenciesHandler::IsQuestionnableFile($sDir)) { echo "ERROR found INVALID denied test dir: '$sDir'\n"; throw new \RuntimeException("$sDir is in the denied list but doesn't comply with the rule (see IsQuestionnableFolder method)"); } if (false === file_exists($sDir)) { echo "INFO $sDir is in denied list, but not existing on disk => skipping !\n"; continue; } try { if(is_dir($sDir)){ SetupUtils::rrmdir($sDir); } else{ unlink($sDir); } echo "✔️ Remove denied test dir: '$sDir'\n"; } catch (\Exception $e) { echo "\n❌ FAILED to remove denied test dir: '$sDir'\n"; } } $aAllowedAndDeniedDirs = array_merge( $oDependenciesHandler->ListAllowedFilesAbsPaths(), $oDependenciesHandler->ListDeniedFilesAbsPaths() ); $aExistingDirs = $oDependenciesHandler->ListAllFilesAbsPaths(); $aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs); if (false === empty($aMissing)) { echo "Some new tests dirs exists !\n" ." They must be declared either in the allowed or denied list in {$sDependenciesHandlerFQCN}\n" .' List of dirs:'."\n".var_export($aMissing, true)."\n"; } // Ensure separation with following scripts echo "\n";