Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions dev/src/Command/ComponentExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ protected function configure()

EOF)
->addArgument('code', InputArgument::REQUIRED, 'Path to a file or PHP code to execute')
->addOption('component', 'c', InputOption::VALUE_REQUIRED, 'If specified, display repo info for this component only', '')
->addOption(
'component',
'c',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'If specified, execute code for this component only',
[]
)
->addOption('token', 't', InputOption::VALUE_REQUIRED, 'Github token to use for authentication', '')
->addOption('packagist-token', 'p', InputOption::VALUE_REQUIRED, 'Packagist token for the webhook')
;
Expand All @@ -72,9 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$github = new GitHub(new RunShell(), $http, $input->getOption('token'), $output);
$packagist = new Packagist($http, self::PACKAGIST_USERNAME, $input->getOption('packagist-token') ?? '');

$componentName = $input->getOption('component');
$components = $componentName ? [new Component($componentName)] : Component::getComponents();

$components = Component::getComponents($input->getOption('component'));
$code = $input->getArgument('code');
if (file_exists($code)) {
$executeFn = require $code;
Expand Down
8 changes: 7 additions & 1 deletion dev/src/Command/ComponentInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ protected function configure()
$this->setName('component:info')
->setAliases(['info'])
->setDescription('list info of a component or the whole library')
->addOption('component', 'c', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'get info for a single component', [])
->addOption(
'component',
'c',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'get info for a single component',
[]
)
->addOption('csv', '', InputOption::VALUE_OPTIONAL, 'export findings to csv.', false)
->addOption('fields', 'f', InputOption::VALUE_REQUIRED, sprintf(
'Comma-separated list of fields. Prefix with "+" to add to default filters, or use "all" for all fields.'
Expand Down
11 changes: 6 additions & 5 deletions dev/src/Command/ComponentUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ protected function configure()
{
$this->setName('component:update')
->setDescription('Update one or all components using Owlbot')
->addArgument(
->addOption(
'component',
InputArgument::OPTIONAL,
'The name of the component to update. If not provided, all components will be updated.'
'c',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'Add to the readme of the specified component',
[]
)
->addOption(
'googleapis-gen-path',
Expand All @@ -82,7 +84,6 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output): int
{
$componentName = $input->getArgument('component');
$googleApisGenDir = realpath($input->getOption('googleapis-gen-path'));
$unsafeTimeout = $input->getOption('timeout');

Expand All @@ -104,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->checkDockerAvailable();

// Find components to update
$components = Component::getComponents($componentName ? [$componentName] : []);
$components = Component::getComponents($input->getArgument('component'));
foreach ($components as $component) {
$componentName = $component->getName();
$output->writeln("\n<info>Running Owlbot in $componentName</info>");
Expand Down
36 changes: 31 additions & 5 deletions dev/src/Command/ComponentUpdateDepsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,37 @@ protected function configure()
->setDescription('update a dependency across all components')
->addArgument('package', InputArgument::REQUIRED, 'Package name to update, e.g. "google/gax"')
->addArgument('version', InputArgument::OPTIONAL, 'Package version to update to, e.g. "1.4.0"', '')
->addOption('component', 'c', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'bumps deps for the specified component/file')
->addOption('bump', '', InputOption::VALUE_NONE, 'Bump to latest version of the package')
->addOption('add', '', InputOption::VALUE_OPTIONAL, 'Adds the dep if it doesn\'t exist (--add=dev for require-dev)', false)
->addOption('no-dev', '', InputOption::VALUE_NONE, 'Only updates the dep if its in "require" (deps in "require-dev" are left alone)')
->addOption('local', '', InputOption::VALUE_NONE, 'Add a link to the local component')
->addOption(
'component',
'c',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'bumps deps for the specified component/file'
)
->addOption(
'bump',
'',
InputOption::VALUE_NONE,
'Bump to latest version of the package'
)
->addOption(
'add',
'',
InputOption::VALUE_OPTIONAL,
'Adds the dep if it doesn\'t exist (--add=dev for require-dev)',
false
)
->addOption(
'no-dev',
'',
InputOption::VALUE_NONE,
'Only updates the dep if its in "require" (deps in "require-dev" are left alone)'
)
->addOption(
'local',
'',
InputOption::VALUE_NONE,
'Add a link to the local component'
)
;
}

Expand Down
17 changes: 14 additions & 3 deletions dev/src/Command/ComponentUpdateReadmeSampleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,19 @@ protected function configure()
{
$this->setName('component:update:readme-sample')
->setDescription('Add a sample to a component')
->addOption('component', 'c', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add to the readme of the specified component', [])
->addOption('update', '', InputOption::VALUE_NONE, 'updates the sample in the readme if it exists');
->addOption(
'component',
'c',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'Add to the readme of the specified component',
[]
)
->addOption(
'force',
'',
InputOption::VALUE_NONE,
'updates the sample in the readme if it exists'
);
;
}

Expand Down Expand Up @@ -76,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$sample = "```php\n" . $sample . "\n```";
if (preg_match('/### Sample\n\n(```(.|\n)*```)/', $readme, $matches)) {
$output->writeln('Sample already exists in <info>' . $component->getName() . '</> README.md');
if (!$input->getOption('update')) {
if (!$input->getOption('force')) {
continue;
}
if ($matches[1] === $sample) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testUpdateFailsWithInvalidGoogleapisDir()
$commandTester = new CommandTester($application->get('component:update'));

$commandTester->execute([
'component' => self::COMPONENT_NAME,
'--component' => self::COMPONENT_NAME,
'--googleapis-gen-path' => $googleapisGenPath,
]);
}
Expand All @@ -100,7 +100,7 @@ public function testUpdateFailsWithNoDocker()
$commandTester = new CommandTester($application->get('component:update'));

$commandTester->execute([
'component' => self::COMPONENT_NAME,
'--component' => self::COMPONENT_NAME,
'--googleapis-gen-path' => self::$tmpDir,
]);
}
Expand All @@ -120,7 +120,7 @@ public function testUpdateFailsWithInvalidComponentName()
$commandTester = new CommandTester($application->get('component:update'));

$commandTester->execute([
'component' => 'NonExistantComponent',
'--component' => 'NonExistantComponent',
'--googleapis-gen-path' => self::$tmpDir,
]);
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public function testUpdateComponentSucceeds()
$commandTester = new CommandTester($application->get('component:update'));

$commandTester->execute([
'component' => self::COMPONENT_NAME,
'--component' => self::COMPONENT_NAME,
'--googleapis-gen-path' => $googleapisGenPath,
]);

Expand All @@ -213,7 +213,7 @@ public function testUpdateComponentErrorsWithNonNumericTimeout()
'Y' // Does this information look correct? [Y/n]
]);
$commandTester->execute([
'component' => self::COMPONENT_NAME,
'--component' => self::COMPONENT_NAME,
'--timeout' => 'not-a-number',
]);
}
Expand Down
Loading