Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistLiberateWorkflow.php
Show All 25 Lines | return array( | ||||
->setHelp( | ->setHelp( | ||||
pht('Perform a clean rebuild, ignoring caches. Thorough, but slow.')), | pht('Perform a clean rebuild, ignoring caches. Thorough, but slow.')), | ||||
$this->newWorkflowArgument('argv') | $this->newWorkflowArgument('argv') | ||||
->setWildcard(true), | ->setWildcard(true), | ||||
); | ); | ||||
} | } | ||||
public function runWorkflow() { | public function runWorkflow() { | ||||
$log = $this->getLogEngine(); | |||||
$argv = $this->getArgument('argv'); | $argv = $this->getArgument('argv'); | ||||
if (count($argv) > 1) { | if (count($argv) > 1) { | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht( | pht( | ||||
'Provide only one path to "arc liberate". The path should identify '. | 'Provide only one path to "arc liberate". The path should identify '. | ||||
'a directory where you want to create or update a library.')); | 'a directory where you want to create or update a library.')); | ||||
} else if (!$argv) { | } else if (!$argv) { | ||||
$log->writeStatus( | |||||
pht('SCAN'), | |||||
pht('Searching for libraries in the current working directory...')); | |||||
$init_files = id(new FileFinder(getcwd())) | $init_files = id(new FileFinder(getcwd())) | ||||
->withPath('*/__phutil_library_init__.php') | ->withPath('*/__phutil_library_init__.php') | ||||
->find(); | ->find(); | ||||
if (!$init_files) { | if (!$init_files) { | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht( | pht( | ||||
'Unable to find any libraries under the current working '. | 'Unable to find any libraries under the current working '. | ||||
'directory. To create a library, provide a path.')); | 'directory. To create a library, provide a path.')); | ||||
} | } | ||||
$paths = array(); | $paths = array(); | ||||
foreach ($init_files as $init) { | foreach ($init_files as $init) { | ||||
$paths[] = Filesystem::resolvePath(dirname($init)); | $paths[] = Filesystem::resolvePath(dirname($init)); | ||||
} | } | ||||
} else { | } else { | ||||
$paths = array( | $paths = array( | ||||
Filesystem::resolvePath(head($argv)), | Filesystem::resolvePath(head($argv)), | ||||
); | ); | ||||
} | } | ||||
foreach ($paths as $path) { | foreach ($paths as $path) { | ||||
$log->writeStatus( | |||||
pht('WORK'), | |||||
pht('Updating library: %s', Filesystem::readablePath($path))); | |||||
$this->liberatePath($path); | $this->liberatePath($path); | ||||
} | } | ||||
$log->writeSuccess( | |||||
pht('DONE'), | |||||
pht('Updated %s librarie(s).', phutil_count($paths))); | |||||
return 0; | return 0; | ||||
} | } | ||||
private function liberatePath($path) { | private function liberatePath($path) { | ||||
if (!Filesystem::pathExists($path.'/__phutil_library_init__.php')) { | if (!Filesystem::pathExists($path.'/__phutil_library_init__.php')) { | ||||
echo tsprintf( | echo tsprintf( | ||||
"%s\n", | "%s\n", | ||||
pht( | pht( | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |